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.]
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
搬運自: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 為每一條數(shù)據(jù), index 索引
</a-table>
方法三:
<a-table
:columns="columns"
:data-source="tableData"
size="middle"
rowKey="id"> // id為 tableData 中的一個屬性 !!! 這里的rowKey不需要冒號
</a-table>
總結(jié)
以上是生活随笔為你收集整理的ant-design-vue——Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Centos7下安装netstat
- 下一篇: Linux内核分析06