關於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>
差不多就這樣