在ProFrom 下使用ProFormList时,ProFromList下存在若干个FormItem的时候,我这个时候想更改ProFormList下的某个FormItem的值应该怎么做? #9237
Unanswered
kelisiWu123
asked this question in
Q&A
Replies: 1 comment
-
你可以通过 ProForm 的 formRef 或 ProFormInstance,使用 setFieldsValue 方法来更改 ProFormList 下某个 FormItem 的值。假设你的 ProFormList 的 name 是 "list",每个 FormItem 有字段 "fieldA",要修改第 2 个(索引为 1)FormItem 的 "fieldA" 值,可以这样: formRef.current?.setFieldsValue({
list: [
/* 第 0 个项 */,
{ fieldA: '新值' }, // 第 1 个项,只需要设置你要修改的字段
/* 第 2 个项 */,
]
}); 实际操作时,建议先用 getFieldsValue 拿到当前 list 的值,修改对应索引的字段后再 setFieldsValue。这样不会影响其他项。 详细用法和 API 可以参考 ProForm 官方文档 和 Ant Design Form.List 文档。 To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
在ProFrom 下使用ProFormList时,ProFromList下存在若干个FormItem的时候,我这个时候想更改ProFormList下的某个FormItem的值应该怎么做?
Beta Was this translation helpful? Give feedback.
All reactions