【bug记录】Duplicate keys detected: ‘*‘. This may cause an update error.

vue项目中报了一个这样的错:Duplicate keys detected: '*'. This may cause an update error.

【bug记录】Duplicate keys detected: ‘*‘. This may cause an update error._第1张图片 

虽然不影响使用,但是报错还是得解决的

只要一进入该页面,就会出这个红色的错误,网上查了资料,说是v-for循环里,key值可能重复了,所以会报这个错。

查看了下,页面果然有v-for循环

 【bug记录】Duplicate keys detected: ‘*‘. This may cause an update error._第2张图片

key值是必须唯一的,如果重复就会报错
可以把key值改为index(其实就是用索引做key值),就可以避免这个情况: 

【bug记录】Duplicate keys detected: ‘*‘. This may cause an update error._第3张图片

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