Commit f43bc792befba702245d8f742086a307c5a44f90
1 parent
57bd5393
fix #5060
Showing
1 changed file
with
19 additions
and
1 deletions
Show diff stats
src/components/input/input.vue
... | ... | @@ -30,6 +30,9 @@ |
30 | 30 | @keydown="handleKeydown" |
31 | 31 | @focus="handleFocus" |
32 | 32 | @blur="handleBlur" |
33 | + @compositionstart="handleComposition" | |
34 | + @compositionupdate="handleComposition" | |
35 | + @compositionend="handleComposition" | |
33 | 36 | @input="handleInput" |
34 | 37 | @change="handleChange"> |
35 | 38 | <div :class="[prefixCls + '-group-append']" v-if="append" v-show="slotReady"><slot name="append"></slot></div> |
... | ... | @@ -62,6 +65,9 @@ |
62 | 65 | @keydown="handleKeydown" |
63 | 66 | @focus="handleFocus" |
64 | 67 | @blur="handleBlur" |
68 | + @compositionstart="handleComposition" | |
69 | + @compositionupdate="handleComposition" | |
70 | + @compositionend="handleComposition" | |
65 | 71 | @input="handleInput"> |
66 | 72 | </textarea> |
67 | 73 | </div> |
... | ... | @@ -179,7 +185,8 @@ |
179 | 185 | slotReady: false, |
180 | 186 | textareaStyles: {}, |
181 | 187 | showPrefix: false, |
182 | - showSuffix: false | |
188 | + showSuffix: false, | |
189 | + isOnComposition: false | |
183 | 190 | }; |
184 | 191 | }, |
185 | 192 | computed: { |
... | ... | @@ -244,7 +251,18 @@ |
244 | 251 | this.dispatch('FormItem', 'on-form-blur', this.currentValue); |
245 | 252 | } |
246 | 253 | }, |
254 | + handleComposition(event) { | |
255 | + if (event.type === 'compositionstart') { | |
256 | + this.isOnComposition = true; | |
257 | + } | |
258 | + if (event.type === 'compositionend') { | |
259 | + this.isOnComposition = false; | |
260 | + this.handleInput(event); | |
261 | + } | |
262 | + }, | |
247 | 263 | handleInput (event) { |
264 | + if (this.isOnComposition) return; | |
265 | + | |
248 | 266 | let value = event.target.value; |
249 | 267 | if (this.number && value !== '') value = Number.isNaN(Number(value)) ? value : Number(value); |
250 | 268 | this.$emit('input', value); | ... | ... |