Explorar o código

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

cinwell.li %!s(int64=8) %!d(string=hai) anos
pai
achega
4992d59cdd
Modificáronse 1 ficheiros con 4 adicións e 11 borrados
  1. 4 11
      packages/form/src/form-item.vue

+ 4 - 11
packages/form/src/form-item.vue

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