Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]
Warning: [antdv: Table] Each record in dataSource of table should have a unique `key` prop, or set `rowKey` of Table to an unique primary key
提示因為使用 ant design的表格工具但是沒有指明表格每一行對應的 rowKey。
解決辦法:? [? :rowKey ]? (帶:的表示綁定的是表達式,帶冒號的表示綁定的是表達式,不帶的表示綁定的就是值)
注意
在 Table 中,dataSource
?和?columns
?里的數據值都需要指定?key
?值。對于?dataSource
?默認將每列數據的?key
?屬性作為唯一的標識。
如果你的數據沒有這個屬性,務必使用?rowKey
?來指定數據列的主鍵。若沒有指定,控制臺會出現缺少 key 的提示,表格組件也會出現各類奇怪的錯誤。
// 比如你的數據主鍵是 uid
return <Table rowKey="uid" />;
// 或
return <Table rowKey={record => record.uid} />;
有些時候后端就不給,那就自己造
:row-key="(r, i) => i.toString()"