Closed JoelynZhou closed 1 year ago
1.依赖仓库的版本(Dependencies versions):
react:18.2.0 form-render:2.2.15 antd:5.9.4 2.问题描述(Bug description): setValueByPath 修改 list 下的属性不生效
3.出现问题的 schema demo(Reproduction schema demo):
const watch = { select1: (val, index) => { console.log("val", val, index); form.setValueByPath("list[].input", val); } }; const schema = { type: "object", displayType: "row", properties: { select1: { title: "输入框 A", type: "string" }, select2: { title: "输入框 B", type: "string" }, list: { title: "对象数组", type: "array", display: "inline", default: [{}], items: { type: "object", title: "基础信息", properties: { input: { title: "输入框", type: "string" } } } } } };
4.最小复现 demo(Reproduction demo): https://codesandbox.io/s/quizzical-sun-5pht34?file=/App.tsx:160-866
使用错误,form.setValueByPath('list', [])
"list[].input" 这种路径是错误的,你现在是在设置 list 的 里面的 value 值,而不是 schema。应该统一设置 form.setValueByPath('list', [])
1.依赖仓库的版本(Dependencies versions):
react:18.2.0 form-render:2.2.15 antd:5.9.4 2.问题描述(Bug description): setValueByPath 修改 list 下的属性不生效
3.出现问题的 schema demo(Reproduction schema demo):
4.最小复现 demo(Reproduction demo): https://codesandbox.io/s/quizzical-sun-5pht34?file=/App.tsx:160-866