vue3.0 AntDesignVue2.0 table的rowkey报错问题解决方法
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` pr
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()"
更多推荐
所有评论(0)