vue使用v-for时vscode报错不影响代码正常启动,但是编译器会出现爆红影响观感!
报错如下:
[vue/require-v-for-key] Elements in iteration expect to have 'v-bind:key' directives.eslint-plugin-vue
原因:Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的。eslint会检测出现bug,并在编译器里出现提示。
俩种解决:
1.在v-for 后添加 :key='item'
2.打开vs code设置,搜索 settings.json文件,在其中加入以下设置:
"vetur.validation.template": false,