Ant Design Vue-Table报错:warning.js?2149:7
今儿使用蚂蚁组件库的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.] 。记录一下这是因为columns中定义的默认key值在返回的数据中没有当前的这个字段造成的,
·
今儿使用蚂蚁组件库的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.] 。记录一下
这是因为columns中定义的默认key值在返回的数据中没有当前的这个字段造成的,一个是使用rowKey默认指定一个对应的键值对,或者使用类似v-for循环中的下标index来代替
因此在table组件里面引入下面字段即可:
:rowKey="(record,index)=>{return index}"
引入后如下:
<a-table :columns="columns" :data-source="data" :rowKey="(record,index)=>{return index}" />
这样就不会报错了
更多推荐
已为社区贡献3条内容
所有评论(0)