react的antd表格数据回显在form表单中
1、首先为table添加编辑按钮
{
title: '操作',
align: 'center',
render: (_: any, record: any) => (
<div style={
{ display: 'flex', alignItems: 'center', justifyContent: 'space-evenly' }}>
<Button
size="small"
onClick={() => deitor(record)}
style={
{ marginRight: '10px', backgroundColor: '#F3F9FF' }}
color="primary"
variant="outlined"
icon={<EditFilled />}
>
编辑
</Button>
</div>
),
},
2、然后在用函数接过来数据,使用form.setFieldsValue({})进行回显
function deitor(item: any) {
form.setFieldsValue({
id: item.id,
content: item.content,
name: item.name,
});
}