不能将类型 columns ProColumnsCoreRoleConfigListItem; editable type string; editableKeys Key; onSave rowKey string row any = Promisevoid; onChange Dispatch; actionRender row any config any defaultDoms any
需要在ConfigCoreTable组件的类型定义中添加columns和editable属性,可以通过interface或type来完成:
import { ProColumns } from '@ant-design/pro-table';
import { Dispatch, ReactNode } from 'react';
interface ConfigCoreTableProps {
columns: ProColumns[];
editable: {
type: string;
editableKeys: string[];
onSave: (rowKey: string, row: any) => Promise<void>;
onChange: Dispatch<string[]>;
actionRender: (row: any, config: any, defaultDoms: any) => ReactNode[];
};
children?: ReactNode;
}
const ConfigCoreTable: React.FC<ConfigCoreTableProps> = ({ columns, editable, ...otherProps }) => {
return (
<EditableProTable
{...otherProps}
columns={columns}
editable={editable}
rowKey="id"
options={false}
scroll={{ y: 600 }}
cardProps={{
bodyStyle: {
padding: 0,
},
}}
recordCreatorProps={false}
bordered
/>
);
};
export default ConfigCoreTable;
然后在使用ConfigCoreTable组件时,需要传递columns和editable属性,例如:
<ConfigCoreTable
columns={columns}
editable={{
type: 'multiple',
editableKeys,
onSave: async (rowKey, row) => {
// ...
},
onChange: setEditableKeys,
actionRender: (row, config, defaultDoms) => {
return [defaultDoms.save, defaultDoms.cancel];
},
}}
/>
``
原文地址: https://www.cveoy.top/t/topic/fcWB 著作权归作者所有。请勿转载和采集!