-
场景: 遇到的问题: 解决方式: <ArrayField
name="arrayTable"
component={[MyArrayTable, props]}
></ArrayField> 使用renderProps的方式 <ArrayField name="arrayTable">
{() => {
return <MyArrayTable {...props}></MyArrayTable>;
}}
</ArrayField> 2.使用ArrayField时,传递给ArrayField的name属性会导致路径多出一层(比如:a.b变成了a.b.arrayTable)。尝试使用basePath进行处理,但会导致页面卡死。 const ArrayTable = props => {
const field = useField<Formily.Core.Models.Field>();
let arr = field.address.toArr();
let name = arr[arr.length - 1];
let basePath = field.address.parent().toString();
return (
<ArrayField
name="arrayTable"
basePath={basePath}
component={[MyArrayTable, props]}
></ArrayField>
);
}; 最终解决: 感谢大佬的耐心指导。。 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
用法不对,ArrayTable内部不需要再使用ArrayField了,ArrayField应该作为它的父组件,具体使用案例已更新 https://react.formilyjs.org/api/components/array-field#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%94%A8%E4%BE%8B |
Beta Was this translation helpful? Give feedback.
用法不对,ArrayTable内部不需要再使用ArrayField了,ArrayField应该作为它的父组件,具体使用案例已更新 https://react.formilyjs.org/api/components/array-field#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%94%A8%E4%BE%8B