用了 Ant Design Vue 之后,遇到了一些 iView 中没遇到过的问题,只能一个一个解决。在使用 Table 组件渲染后台返回数据时,提示 antdv: Each record in table should have a unique key prop,or set rowKey to an unique primary key
在这里插入图片描述
大致意思就是表格里每条数据都需要一个 key,只能满足它的要求 =_=

原来的 a-table

<a-table :dataSource="data1.data" :columns="columns" bordered :pagination="false">
</a-table>

现在的 a-table,其实就是加上 rowKey="id"

<a-table :dataSource="data1.data" :columns="columns" bordered :pagination="false" rowKey="id">
</a-table>

这个 id 需要是后台数据返回的那个 id
:rowKey=‘record=>record.id’ 这种写法也没问题
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐