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