用的VS Code 工具,安裝了vetur插件,報錯了如下
[eslint-plugin-vue] [vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' directives.eslint-plugin-vue
在Vue 的版本里,當在組件中使用v-for時,key是必須的。
解決辦法:
在文件 –>首選項 –>設置 –>在搜索框中輸入:vetur.validation.template–》找到vetur.validation.template:true–》
將vetur.validation.template:true在右欄框中進行重置為false就ok了。
如果沒有這局代碼 就添加一句: "vetur.validation.template": false