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>

 

差不多就這樣

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM