-
CodeSandBoxhttps://codesandbox.io/s/little-framework-1x6y5?file=/App.tsx 问题当前 merge 使用的是 deep merge 策略导致无法重置 object field 的值。 期望只在 form values 这一层进行 merge,具体到某个字段的时候应该直接替换。 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
这行为是正确的,你改成overwrite就行了 |
Beta Was this translation helpful? Give feedback.
-
Override 会把整个 values 替换掉,这也不是我想要的行为。 |
Beta Was this translation helpful? Give feedback.
-
import { createForm } from '../shared'
const data = {
a: {
b: 1,
},
c: 2,
}
const form = createForm({
values: data,
})
form.setValues({
a: {},
})
console.log(form.values)
// 期待输出:{ a: {}, c: 2 } |
Beta Was this translation helpful? Give feedback.
-
现在有个问题是 form 中有多个 object value,我没法使用 form.setValues 来批量重置值。 |
Beta Was this translation helpful? Give feedback.
-
使用深合并是基于什么原因呢,感觉日常开发中浅合并使用的频率更高吧? |
Beta Was this translation helpful? Give feedback.
这行为是正确的,你改成overwrite就行了