ant-design-vue——Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]
生活随笔
收集整理的这篇文章主要介绍了
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.]的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Centos7下安装netstat
- 下一篇: API测试之Postman使用完全指南(