[Bug, Report], form, resetFields:Execute, than, once, The, value, of, the, form, is, more, initialized, to,, the, first, selected, value
Element UI version
1.4.1
OS/Browsers version
window7 64 chrom 58.0.3029.110
Vue version
2.4.2
Reproduction Link
https://jsfiddle.net/pj71jkyw/436/
Steps to reproduce
- Click on the first line of the table to edit the data and close the dialog, execute the resetFields () method
- Click on the second line of the table to edit the data and close the dialog, execute the resetFields () method, and the second line of data will be initialized to the first row of data
1.点击table中的第一行编辑数据后关闭dialog,执行resetFields()方法 2.点击table中的第二行编辑数据后关闭dialog,执行resetFields()方法,第二行数据会被初始化成第一行数据
What is Expected?
Multiple use of resetFields () will not be initialized to the initial selected data 多次使用resetFields() 后 不会被初始化为初始选择的数据
What is actually happening?
Will be initialized to the initial data 会被初始化为初始的数据
Translation of this issue:
Element UI version
1.4.1
OS/Browsers version
Window7 64, chrom, 58.0.3029.110
Vue version
2.4.2
Reproduction Link
https://jsfiddle.net/pj71jkyw/436/
Steps to reproduce
Click on the first line of table to the edit the data and close the dialog execute the resetFields () method
"Click line, on, the, second, of, the, table, edit, the, data, and, the, dialog, execute, the, resetFields (), method, and, the, second, line, of, data, will,, be, initialized,, to, close, the, to, first, row, data, of."
-
click on the first line in the table to edit data, then close dialog and execute the resetFields () method
-
click on the second line in table to edit the data, then close dialog, execute the resetFields () method, and the second row of data is initialized to the first row of data
What is Expected?
Multiple, use, of, resetFields (), will, not, be, initialized, to, the,, initial, selected, data Multiple use of resetFields () will not be initialized to the initial selection of data
What is actually happening?
Will, be, initialized, to, the, initial, data
Will be initialized to the initial data
resetFields 会把表单回退为第一次被赋值的状态,所以在 el-form 上加一个
v-if,每次强制重新创建即可:https://jsfiddle.net/pj71jkyw/438/
这个resetFields 在dialog的form中,竟然也不是重置到data中定义的初始值,有点怪怪的感觉
解决方案https://jsfiddle.net/zhangjianliang/b47oyk23/1/
试了一下,@zhang463291046 的方案是可行的,在我的场景下,@Leopoldthecoder 的方案也没有管用
感谢 @zhang463291046