vue控制台报错Duplicate keys detected: 'xxxx'. This may cause an update error.解决方案
生活随笔
收集整理的這篇文章主要介紹了
vue控制台报错Duplicate keys detected: 'xxxx'. This may cause an update error.解决方案
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
key值是必須唯一的,如果重復就會報錯
可以把key值改為index(其實就是用索引做key值),就可以避免這個情況
添加一個索引key即可
<tr v-for="(item,index) in books" v-bind:key="index"><td>{{item.id}}</td><td>{{item.name}}</td><td>{{item.author}}</td></tr>總結
以上是生活随笔為你收集整理的vue控制台报错Duplicate keys detected: 'xxxx'. This may cause an update error.解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Git 汇总
- 下一篇: Apache JMeter 字体、字体大