問(wèn)題描述:
在uniapp小程序項(xiàng)目中使用多層for循環(huán)時(shí),小程序端提示:uniapp v-for 暫不支持循環(huán)數(shù)據(jù)
,以至于獲取不到循環(huán)的數(shù)據(jù)。
<view v-for="(item,index) in list" :key="item.id">
<view v-for="child in item.children" @click="fn(child.id)" :key="child.id">
....
....
fn(id){
console.log(id); // undefined
}
解決
1. 確保 v-for 循環(huán)的數(shù)據(jù)確實(shí)是Array或者是Object;
2. 檢查 key ,是否存在并且是唯一的;文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-808415.html
當(dāng)引用的 key 不存在時(shí),是不會(huì)有錯(cuò)誤提示的。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-808415.html
到了這里,關(guān)于uniapp小程序v-for提示“不支持循環(huán)數(shù)據(jù)”的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!