Element: When [Bug Report] Form is in dialog, you cannot reset the initial value in data with resetFields

Created on 25 Jul 2017  ·  3Comments  ·  Source: ElemeFE/element

Element UI version

1.4.0

OS/Browsers version

window 10/chrome

Vue version

2.3.3

Reproduction Link

https://jsfiddle.net/d3oLzth9/6/

Steps to reproduce

点击编辑打开dialog赋予data里form的值后再点击添加按钮resetFields,无法用resetFields重置回form里面初始的值,

What is Expected?

resetFields后初始的值不应该是data里最初始的值吗?

What is actually happening?

Most helpful comment

Dialog 中的内容是懒加载的,目前 edit 方法的写法导致 Form 刚加载出来时值就已经是新的了,所以 resetFields 也只能回到新值。用 nextTick 包一下就好:https://jsfiddle.net/d3oLzth9/8/

All 3 comments

Translation of this issue:

Element UI version

1.4.0

OS/Browsers version

Window 10/chrome

Vue version

2.3.3

Reproduction Link

https://jsfiddle.net/d3oLzth9/6/

Steps to reproduce

Click the edit, open dialog, assign the value of data in form, and then click the Add button resetFields, and you can't reset the initial value in form with resetFields,

What is Expected?

Should the initial value not be the initial value in data after resetFields?

What is actually happening?

Dialog 中的内容是懒加载的,目前 edit 方法的写法导致 Form 刚加载出来时值就已经是新的了,所以 resetFields 也只能回到新值。用 nextTick 包一下就好:https://jsfiddle.net/d3oLzth9/8/

这个问题搞哭了 先编辑再添加就重置失败 呜呜
nextTick方式解决了

再问个问题 @Leopoldthecoder 为什么第一次调用resetFields时控制台会报错 为什么第二次就不会了 怎么解决这个问题

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yuchonghua picture yuchonghua  ·  3Comments

zhguokai picture zhguokai  ·  3Comments

chao-hua picture chao-hua  ·  3Comments

yorululu picture yorululu  ·  3Comments

akaylh picture akaylh  ·  3Comments