Vue报错:Avoid using non-primitive value as key, use string/number value instead

简述

Avoid using non-primitive value as key, use string/number value instead.
意思是:避免使用非基本值作为键,而是使用字符串/数字值

示例

d渲染出来的数据是一个对象

 
{{d.title}}
{{d.content}}

报错的意思是 不要用对象或是数组作为key,用string或value作为key

修改后如下

d对象中有一个唯一值:d.id

 
{{d.title}}
{{d.content}}

根据循环读取数据的类型进行修改key中的值,也可以如下:

 
{{d.title}}
{{d.content}}

你可能感兴趣的:(vue,vue.js,前端,javascript)