diff --git a/src/_common b/src/_common index 1d69c2169..81d37e52b 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit 1d69c2169a645e6ce4655d2b5b29d86a797aa8e7 +Subproject commit 81d37e52b472e1df565df4f90838f6c79ab794fa diff --git a/src/form/FormList.tsx b/src/form/FormList.tsx index bc03624a1..d4f3bf609 100644 --- a/src/form/FormList.tsx +++ b/src/form/FormList.tsx @@ -10,7 +10,14 @@ const FormList = (props: TdFormListProps) => { const { name, initialData = [], rules, children } = props; const [initialValue, setInitialValue] = useState(initialData); - const [fields, setFields] = useState>([]); + const [fields, setFields] = useState>( + initialData.map((data, index) => ({ + key: (key += 1), + name: index, + isListField: true, + ...data, + })), + ); const formListMapRef = useRef(new Map()); // 收集 formItem 实例 const formListRef = useRef(); // 当前 formList 实例 @@ -40,6 +47,7 @@ const FormList = (props: TdFormListProps) => { }) .map((field, index) => Object.assign(field, { name: index })); + setInitialValue(initialValue.filter((_, idx) => idx !== index)); setFields(nextFields); }, move(from: number, to: number) {