From f43bc792befba702245d8f742086a307c5a44f90 Mon Sep 17 00:00:00 2001 From: 梁灏 Date: Mon, 24 Dec 2018 10:15:04 +0800 Subject: [PATCH] fix #5060 --- src/components/input/input.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/components/input/input.vue b/src/components/input/input.vue index 912b72c..9c1cc50 100644 --- a/src/components/input/input.vue +++ b/src/components/input/input.vue @@ -30,6 +30,9 @@ @keydown="handleKeydown" @focus="handleFocus" @blur="handleBlur" + @compositionstart="handleComposition" + @compositionupdate="handleComposition" + @compositionend="handleComposition" @input="handleInput" @change="handleChange">
@@ -62,6 +65,9 @@ @keydown="handleKeydown" @focus="handleFocus" @blur="handleBlur" + @compositionstart="handleComposition" + @compositionupdate="handleComposition" + @compositionend="handleComposition" @input="handleInput"> @@ -179,7 +185,8 @@ slotReady: false, textareaStyles: {}, showPrefix: false, - showSuffix: false + showSuffix: false, + isOnComposition: false }; }, computed: { @@ -244,7 +251,18 @@ this.dispatch('FormItem', 'on-form-blur', this.currentValue); } }, + handleComposition(event) { + if (event.type === 'compositionstart') { + this.isOnComposition = true; + } + if (event.type === 'compositionend') { + this.isOnComposition = false; + this.handleInput(event); + } + }, handleInput (event) { + if (this.isOnComposition) return; + let value = event.target.value; if (this.number && value !== '') value = Number.isNaN(Number(value)) ? value : Number(value); this.$emit('input', value); -- libgit2 0.21.4