解决Vue中报错:Duplicate keys detected: ‘0‘. This may cause an update error.

在使用vue中发现异常

解决Vue中报错:Duplicate keys detected: ‘0‘. This may cause an update error._第1张图片

原因是在同一个dom节点中包含了两个v-for也就出现了两个key,而这两个key都是遍历的索引,所以两个key的值会是相同的,违反了类似唯一约束的原则。

解决Vue中报错:Duplicate keys detected: ‘0‘. This may cause an update error._第2张图片

解决方法

我们可以不让他们在同一个dom节点内,用一个盒子来隔离他们

解决Vue中报错:Duplicate keys detected: ‘0‘. This may cause an update error._第3张图片

ok了

你可能感兴趣的:(vue,vue)