在 VSCode 中编辑代码时,在有 v-for 的语句下面有一条红色波浪线,鼠标放上去有提示 Elements in iteration expect to have 'v-bind:key' directives.。代码如下:

<p v-for="line in lines">
          {{line}}
</p>

搜索了一下找到了这个讨论https://github.com/vuejs/vetur/issues/261

原来这是 ESLint 的一个 feature,但是我也没启用 ESLint 呀。原来是因为 vetur(Vue.JS 的高亮插件)里自带了 ESLint。

解决方法是打开 VSCode 的 Preferences 里的 Settings,搜索 ESLint,在 Vetur › Validation: Template 下面取消选中 Validate vue-html in <template> using eslint-plugin-vue 即可。

相关文章:

  • 2021-12-24
  • 2022-12-23
  • 2021-05-01
  • 2021-08-30
  • 2021-07-18
猜你喜欢
  • 2022-01-17
  • 2021-07-12
  • 2021-10-01
  • 2021-09-27
  • 2021-10-25
  • 2021-04-01
相关资源
相似解决方案