Commit 4992d59c authored by cinwell.li's avatar cinwell.li Committed by FuryBean

Form: fix reset value, fixed #937 (#1021)

parent bcbee7b4
...@@ -78,8 +78,7 @@ ...@@ -78,8 +78,7 @@
validateDisabled: false, validateDisabled: false,
validating: false, validating: false,
validator: {}, validator: {},
isRequired: false, isRequired: false
initialValue: null
}; };
}, },
methods: { methods: {
...@@ -148,21 +147,15 @@ ...@@ -148,21 +147,15 @@
} }
this.validate('change'); this.validate('change');
},
getInitialValue() {
var value = this.form.model[this.prop];
if (value === undefined) {
return value;
} else {
return JSON.parse(JSON.stringify(value));
}
} }
}, },
mounted() { mounted() {
if (this.prop) { if (this.prop) {
this.dispatch('form', 'el.form.addField', [this]); this.dispatch('form', 'el.form.addField', [this]);
this.initialValue = this.getInitialValue(); Object.defineProperty(this, 'initialValue', {
value: this.form.model[this.prop]
});
let rules = this.getRules(); let rules = this.getRules();
......
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