前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.

Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.

作者头像
拿我格子衫来
发布2022-01-24 17:58:15
5600
发布2022-01-24 17:58:15
举报
文章被收录于专栏:TopFETopFE

在 使用ant-design的表格时 控制台报错

Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.

Warning: [antd: Table] Each record in dataSource of table should have a unique `key` prop, or set `rowKey` of Table to an unique primary key, see

这是因为表格的每行记录应该有一个key来标识每行的独特性, 如果没有的话 会有很多奇怪的问题

在table 的参数 dataSource 中 如果每条有key这个属性, 则默认使用这个属性 如果没有的话 需要显式地指明key

如:

代码语言:javascript
复制
<Table rowKey="id" dataSource={scripts} columns={columns} />

其中 id 是scripts 这个数组中的每条数据的一个属性

官方截图

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档