欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 综合教程 >内容正文

综合教程

ant-design-vue——Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]

发布时间:2023/12/13 综合教程 37 生活家
生活随笔 收集整理的这篇文章主要介绍了 ant-design-vue——Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.] 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

搬运自:https://www.cnblogs.com/dafei4/p/13020211.html

解决办法: [ :rowKey ]

带冒号的表示绑定的是表达式
不带的表示绑定的就是值

方法一:

<a-table
     :columns="columns"
     :data-source="tableData"
     size="middle"
     :rowKey='record=>record.id'> // id为 tableData 中的一个属性
</a-table>

方法二:

<a-table
      :columns="columns"
      :data-source="tableData"
      size="middle"
      :rowKey="(record,index)=>{return index}"> //record 为每一条数据, index 索引
</a-table>

方法三:

<a-table
      :columns="columns"
      :data-source="tableData"
      size="middle"
      rowKey="id">  // id为 tableData 中的一个属性 !!! 这里的rowKey不需要冒号
</a-table>

总结

以上是生活随笔为你收集整理的ant-design-vue——Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。