(for循環上已經綁定了key值)控制臺報了這樣的錯誤,請問這個該怎么解決
v-if 控制臺報錯
慕碼人2483693
2018-09-08 10:28:16
TA貢獻1921條經驗 獲得超9個贊
估計你項目用了esLint檢查,也有v-for,加個:key就好了
<div v-for="(item, index) of items" :key="index">
問題修改后
兩個index沒有問題
用key沒有問題
template不能用:key 所以我覺得樓主代碼的錯誤應該不是截圖的錯誤,我給template用:key后出現以下錯誤
<template> cannot be keyed. Place the key on real elements instead.
改成div或者template里面再套一層div就沒錯了
TA貢獻1802條經驗 獲得超4個贊
鍵值重復,你兩個循環下表都是index,第二個循環用的是第一個循環的index,可能就出現key值為undefined的情況,相當于沒綁定key值
舉報