vue报错:[Vue warn]: Duplicate keys detected: '1'. This may cause an update error.

vue 开发的时候遇到如下错误信息

[Vue warn]: Duplicate keys detected: '1'. This may cause an update error.

found in

---> <Index> at src/views/list/index.vue
       <App> at src/App.vue
         <Root>
[Vue warn]: Duplicate keys detected: '5'. This may cause an update error.

found in

---> <Index> at src/views/list/index.vue
       <App> at src/App.vue
         <Root>
  1. 遇到这样的错误信息则表明 循环里的key值不是字符串类型,这里数字类型是不能进行隐式类型转换的,强制转换成String类型即可
  2. 当key值为for循环的下标时,当列表的位置发生变化,这时候位置变换则会发生失效,只要把key值变成唯一值就行

更多详细知识介绍请访问我的个人主页

猜你喜欢

转载自blog.csdn.net/lucky___star/article/details/88184994