Elements in iteration expect to have 'v-bind:key' directives錯誤的解決辦法


一、錯誤如下
[eslint-plugin-vue]
[vue/require-v-for-key]
Elements in iteration expect to have 'v-bind:key' directives.

Renders the element or template block multiple times based on the source data.

使用VS Code 出現如下問題,如圖

二、解決

  在用vscode編寫vue代碼時,因為安裝的有vetur插件,所以當代碼中有v-for語法時,會提示,“Elements in iteration expect to have 'v-bind:key' directives.”這個錯誤

這是ESLint的功能,對vue進行了eslint檢查。那么我們就把eslint對該插件的檢查關閉,

更改vetur配置            vscode->首選項->設置->搜索(vetur)

 把  "vetur.validation.template": true  改成  false

 保存,我們再看一下vue文件,發現不報錯了。

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM