Elements in iteration expect to have "v-bind:key" directives错误的解决办法

不念不忘少年蓝@ 2023-06-10 15:21 242阅读 0赞

一、错误如下

[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 出现如下问题,如图

948888-20171219183200740-142932590.png

二、解决

  在用vscode编写vue代码时,因为安装的有vetur插件,所以当代码中有v-for语法时,会提示,“Elements in iteration expect to have ‘v-bind:key’ directives.”这个错误

这是ESLint的功能,对vue进行了eslint检查。那么我们就把eslint对该插件的检查关闭,

更改vetur配置 vscode->首选项->设置->搜索(vetur)

948888-20171219183754271-1338533526.png

“vetur.validation.template”: true 改成 false

保存,我们再看一下vue文件,发现不报错了。

更多专业前端知识,请上 【猿2048】www.mk2048.com

发表评论

表情:
评论列表 (有 0 条评论,242人围观)

还没有评论,来说两句吧...

相关阅读