From 88d4a390d0f4fef2782585a1f759591d90d51474 Mon Sep 17 00:00:00 2001 From: pengchongfu Date: Thu, 30 Mar 2017 11:33:44 +0800 Subject: [PATCH] Form: fix form-item resetFields (#3830) (#3840) --- packages/form/src/form-item.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/form/src/form-item.vue b/packages/form/src/form-item.vue index 3a3f1cbc9..c4d282688 100644 --- a/packages/form/src/form-item.vue +++ b/packages/form/src/form-item.vue @@ -161,10 +161,10 @@ let prop = getPropByPath(model, path); - if (Array.isArray(value) && value.length > 0) { + if (Array.isArray(value)) { this.validateDisabled = true; - prop.o[prop.k] = []; - } else if (value !== '') { + prop.o[prop.k] = [].concat(this.initialValue); + } else { this.validateDisabled = true; prop.o[prop.k] = this.initialValue; } @@ -200,8 +200,12 @@ if (this.prop) { this.dispatch('ElForm', 'el.form.addField', [this]); + let initialValue = this.fieldValue; + if (Array.isArray(initialValue)) { + initialValue = [].concat(initialValue); + } Object.defineProperty(this, 'initialValue', { - value: this.fieldValue + value: initialValue }); let rules = this.getRules();