vue 開發(fā)的時(shí)候遇到如下錯(cuò)誤信息
[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>
- 遇到這樣的錯(cuò)誤信息則表明 循環(huán)里的key值不是字符串類型生均,這里數(shù)字類型是不能進(jìn)行隱式類型轉(zhuǎn)換的耳璧,強(qiáng)制轉(zhuǎn)換成String類型即可
- 當(dāng)key值為for循環(huán)的下標(biāo)時(shí),當(dāng)列表的位置發(fā)生變化合敦,這時(shí)候位置變換則會(huì)發(fā)生失效瘟忱,只要把key值變成唯一值就行