Duplicate keys detected: ‘0‘. This may cause an update error.

问题

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

原因

<div v-for=“(item,id) in items” :key="id”>{{item.name}}  
"id”>{{item.address}} div>

:key重复了。
Duplicate keys detected: ‘0‘. This may cause an update error._第2张图片

解决办法

使其key不冲突

<div v-for=“(item,id) in items” :key="'a'+id”>{{item.name}}  
"'b'+id”>{{item.address}} div>

Duplicate keys detected: ‘0‘. This may cause an update error._第3张图片

你可能感兴趣的:(前端碎碎练,前端)