Commit 7791ddb8 authored by 杨南鸿's avatar 杨南鸿

解决输入框第一次验证错误的问题

parent 55d3beef
...@@ -139,7 +139,8 @@ ...@@ -139,7 +139,8 @@
focused: false, focused: false,
isComposing: false, isComposing: false,
passwordVisible: false, passwordVisible: false,
task: null focusTimer: null,
focusOpen: false
}; };
}, },
...@@ -190,10 +191,6 @@ ...@@ -190,10 +191,6 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
lazy: {
type: [Boolean, Object],
default: false
},
tabindex: String tabindex: String
}, },
...@@ -313,9 +310,6 @@ ...@@ -313,9 +310,6 @@
if (this.validateEvent) { if (this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.blur', [this.value]); this.dispatch('ElFormItem', 'el.form.blur', [this.value]);
} }
if (this.lazy) {
this.handleInput(event, true);
}
}, },
select() { select() {
this.getInput().select(); this.getInput().select();
...@@ -362,28 +356,22 @@ ...@@ -362,28 +356,22 @@
this.handleInput(event); this.handleInput(event);
} }
}, },
handleInput(event, refresh) { handleInput(event) {
// should not emit input during composition // should not emit input during composition
// see: https://github.com/ElemeFE/element/issues/10516 // see: https://github.com/ElemeFE/element/issues/10516
if (this.isComposing || (this.lazy && !refresh)) { if (this.isComposing) return;
this.isInput = true;
let _this = this;
clearTimeout(_this.task);
_this.task = setTimeout(() => {
this.handleInput(event, true);
}, 1500);
return;
}
// hack for https://github.com/ElemeFE/element/issues/8548 // hack for https://github.com/ElemeFE/element/issues/8548
// should remove the following line when we don't support IE // should remove the following line when we don't support IE
if (event.target.value === this.nativeInputValue) return; if (event.target.value === this.nativeInputValue) return;
this.$emit('input', event.target.value); clearTimeout(this.focusTimer);
this.focusTimer = setTimeout(() => {
// ensure native input value is controlled this.$emit('input', event.target.value);
// see: https://github.com/ElemeFE/element/issues/12850 // ensure native input value is controlled
this.$nextTick(this.setNativeInputValue); // see: https://github.com/ElemeFE/element/issues/12850
this.$nextTick(this.setNativeInputValue);
}, 300);
}, },
handleChange(event) { handleChange(event) {
this.$emit('change', event.target.value); this.$emit('change', event.target.value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment