在 VSCode 中编辑代码时,在有 v-for
的语句下面有一条红色波浪线,鼠标放上去有提示 Elements in iteration expect to have 'v-bind:key' directives.
。代码以下:html
<p v-for="line in lines"> {{line}} </p>
搜索了一下找到了这个讨论https://github.com/vuejs/vetur/issues/261。vue
原来这是 ESLint 的一个 feature,可是我也没启用 ESLint 呀。原来是由于 vetur(Vue.JS 的高亮插件)里自带了 ESLint。git
解决方法是打开 VSCode 的 Preferences 里的 Settings,搜索 ESLint
,在 Vetur › Validation: Template
下面取消选中 Validate vue-html in <template> using eslint-plugin-vue
便可。github