antD中关于table组件中报这样的警告warning.js?2149:7 Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.] 解决办法

关于antD中warning.js?2149:7 Warning: [antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique primary key.]

含义:[antdv:表中的每条记录都应该有唯一的' key ' prop,或者将' rowKey '设置为唯一的主键。]

一般这种情况的消除就直接用表格的每一行的单独的主键id就行了(后台返回值一般这种列表都会返回主键唯一id,不行的话就用index数组下标也不会重复

<a-table bordered :data-source="dataSource" :columns="columns" :pagination="pagination" :rowKey="record=>record.id">
            <template slot="handle" slot-scope="text,recode">
                <a @click="showInformation(recode)">详情</a>
                <a-divider type="vertical" />
                <a @click="operation(recode)">编辑</a>
            </template>
        </a-table>

 

差不多就这样

 

posted @ 2020-09-21 15:26  程序猿雪儿  阅读(6364)  评论(0编辑  收藏  举报