使用table组件的时候报这个错误Warning: Each child in a list should have a unique "key" prop.Check the render method of Cell2
.应该怎么解决,这个错误是与columns={columns}相关还是与dataSource={data}相关,我在table上面绑定了rowKey='id'还是不能解决。
还有就是他说的是cell2是不是与columns里面的第二项有关,以下是columns的第二项
{
title: '题型类型', //题型类型
dataIndex: record=>record._genreName?record._genreName:record.tqTypeName,
key: data.some((item) => '_genreName' in item) ? '_genreName' : 'tqTypeName',
render: (text, record) => {
let options = optionData;
const currentIndex = options.findIndex((option) => option.genreName === text||option.tqCType === text);
if (currentIndex !== -1) {
options = options.slice(currentIndex);
}
return (
<Select
key={record.id}
value={record._genreName?record._genreName:record.tqTypeName}
onChange={(value) => handleInputChange('_genreName', value, record)}
>
{options.map((option,index) => (
<Option key={index} value={option.genreName||option.tqCType}>
{option.genreName||option.tqCType}
</Option>
))}
</Select>
);
},
width: '15%'
},
key注意要是唯一的