原因:
在用vscode 編寫vue 代碼時,因為安裝的有vetur 插件,所以當代碼中有v-for 語法時,會提示,“Elements in iteration expect to have ‘v-bind:key’ directives.eslint-plugin-vue” 這個錯誤。這是eslint 的功能,對vue 進行了eslint 檢查。
解決:
-
第一種方法,添加 :key 屬性
在v-for 指令后加上:key=“value”
-
第二種方法,修改vetur 配置文章來源:http://www.zghlxwxcb.cn/news/detail-755853.html
路徑:vscode -> File -> Preferences -> Settings
搜索:vetur.validation.template
取消勾選文章來源地址http://www.zghlxwxcb.cn/news/detail-755853.html
到了這里,關于vue 報錯:Elements in iteration expect to have ‘v-bind:key‘ directives.eslint-plugin-vue的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!