Commit f234b161 authored by 杨奕's avatar 杨奕 Committed by GitHub

Select: trigger validation after resetField (#10105)

parent 9f479184
...@@ -217,13 +217,16 @@ ...@@ -217,13 +217,16 @@
let prop = getPropByPath(model, path, true); let prop = getPropByPath(model, path, true);
this.validateDisabled = true;
if (Array.isArray(value)) { if (Array.isArray(value)) {
this.validateDisabled = true;
prop.o[prop.k] = [].concat(this.initialValue); prop.o[prop.k] = [].concat(this.initialValue);
} else { } else {
this.validateDisabled = true;
prop.o[prop.k] = this.initialValue; prop.o[prop.k] = this.initialValue;
} }
/* Select 的值被代码改变时不会触发校验,
这里需要强行触发一次,刷新 validateDisabled 的值,
确保 Select 下一次值改变时能正确触发校验 */
this.broadcast('ElSelect', 'fieldReset');
}, },
getRules() { getRules() {
let formRules = this.form.rules; let formRules = this.form.rules;
......
...@@ -789,6 +789,9 @@ ...@@ -789,6 +789,9 @@
this.$on('handleOptionClick', this.handleOptionSelect); this.$on('handleOptionClick', this.handleOptionSelect);
this.$on('setSelected', this.setSelected); this.$on('setSelected', this.setSelected);
this.$on('fieldReset', () => {
this.dispatch('ElFormItem', 'el.form.change');
});
}, },
mounted() { mounted() {
......
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