一开始是 2 3 4,
然后我删除2之后,
页面展示是错,但是数据是对的。
代码如下:
问题分析:
1.排除浅复制的问题,换成了深复制
2.排除了filter可能导致的问题。换成了splice
3.----1.2之后依然不行。
最后看官网发现有个key。尝试了下,可以了。
解决办法:
key = {record.XX}
const rgRulesColums2: any = [
{
title: '染料(编号)',
dataIndex: 'stuffNum',
align: 'center',
editable: true,
render: (text: any, record: any, index: number) => {
return (
<Input
bordered={false}
defaultValue={record.stuffNum}
key={record.stuffNum}
style={{ textAlign: 'center' }}
onChange={(e) => {
noStuffNumChange(e, text, record, index);
}}
/>
);
},
},
{
title: '燃料分类',
dataIndex: 'type',
align: 'center',
editable: true,
render: (text: any, record: any, index: number) => {
//参数分别为当前行的值,当前行数据,行索引
return (
<Select
onChange={(val: any) => {
noStuffTypeChange(val, index);
}}
key={record.type}
defaultValue={record.type}
style={{ width: 120 }} >
<Option value="普通">{'普通'}</Option>
<Option value="特殊">{'特殊'} </Option>
</Select>
);
},
},
{
title: '删除',
align: 'center',
dataIndex: 'operation',
width: 60,
render: (text: any, record: any, index: number) =>
rgDataSource2.length >= 1 ? (
<Popconfirm title="确定删除吗?" onConfirm={() => andDelete(index)}>
<a>删除</a>
</Popconfirm>
) : null,
},
];