Duplicate keys detected: ‘0‘Duplicate keys detected: ‘1‘报错的原因及解决方法
vue项目Duplicate keys detected: '0'Duplicate keys detected: '1'报错的原因及解决方法
·
打印台报红显示:
Duplicate keys detected: '0'. This may cause an update error.
Duplicate keys detected: '1'. This may cause an update error.
Duplicate keys detected: '2'. This may cause an update error.
原因:
一个template中有两个一样的v-for 需要更改key
<div class="info" v-for="(item, index) in content" :key="index">
<div class="d1">
<p v-text="item.time" class="timeBox"></p>
</div>
</div>
<div class="info2" v-for="(item, index) in content" :key="'index">
<div class="d2">
<p v-text="item.time" class="timeBox"></p>
</div>
</div>
解决办法:
<div class="info2" v-for="(item, index) in content" :key="'different'+index">
<div class="d2">
<p v-text="item.time" class="timeBox"></p>
</div>
</div>
更多推荐
已为社区贡献1条内容
所有评论(0)