VUE Ant table报错 Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]

作者: JONE 分类: 编程 发布时间: 2021-10-29 10:56

相关参考文章:https://www.cnblogs.com/blueswithchenxing/p/14313605.html

VUE Ant table报错 Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]

前端代码  row-key 指定数据字段 index

<a-table
row-key="index"
size="small"
:columns="expressData.columns"
:dataSource="expressData.data"
:pagination="{ pageSize: expressData.pageSize }"
@change="handleTableChange"
>

<span slot="all_request" slot-scope="text, record">{{ record.format_all_request }}</span>
<span slot="abnormal_request" slot-scope="text, record">{{ record.format_abnormal_request }}</span>
<span slot="proportion" slot-scope="text">{{ text }}%</span>
</a-table>

后端代码

expressData.data 数据需返回有 index 字段的数据