-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed as not planned
Labels
Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
4.0.6
Environment
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36, Vue 3.2.36
Reproduction link
Steps to reproduce
- 使用 useForm 运行Form;
- 定义 form model 时,不定义具体的fields;
- 在form 控件(如:Input)中输入值;
- 重置按钮调用 resetFields;
What is expected?
field 的值被重置为 undefined
What is actually happening?
field 的值还是输入时候的值
使用useForm 的时候,此种情况无法重置fields 的值,但是使用ref 的方式是可以重置的。
查看源码发现在useForm resetFields中是通过 Object.assign 来对象合并覆盖实现的,所以如果没有定义fields 就不会被覆盖。
而用 ref 的方式时resetField 是单个赋值重置的。所以即使没有定义也正好被重置为undefined了。