优化FormItemsRenderer

master
LiuJiaNan 2025-12-24 14:27:07 +08:00
parent ee19739b4d
commit 20e89d17b9
2 changed files with 3 additions and 3 deletions

View File

@ -39,7 +39,7 @@ export interface FormListOperations {
/** 当前表单项的数据字段信息 */
field: FormListFieldData;
/** 当前项在列表中的索引位置 */
index: number;
fieldIndex: number;
/** 新增方法 */
add: (defaultValue?: FormValues, insertIndex?: number) => void;
/** 删除方法 */
@ -61,7 +61,7 @@ export interface FormListUniqueProps {
/** 删除按钮的文本,默认 '删除' */
removeButtonText?: string;
/** 表单配置项 */
options: (field: FormListFieldData, operations: FormListOperations) => FormOption[];
options: (field: FormListFieldData, fieldIndex: number, operations: FormListOperations) => FormOption[];
/** 点击新增按钮时的默认值 */
addDefaultValue?: FormValues;
/** 点击新增按钮时插入的索引位置 */

View File

@ -225,7 +225,7 @@ const FormItemsRenderer = ({
// 获取 listOptions
const getListOptions = (listOptions, field, fieldIndex, add, remove, move) => {
return typeof listOptions === "function"
? listOptions(field, { field, fieldIndex, add, remove, move })
? listOptions(field, fieldIndex, { field, fieldIndex, add, remove, move })
: (listOptions ?? []);
};