vscode提示Elements in iteration expect to have 'v-bind:key' directives.解决办法

一、错误提示:

[eslint-plugin-vue]

[vue/require-v-for-key]

Elements in iteration expect to have 'v-bind:key' directives.

如图:

vscode提示Elements in iteration expect to have 'v-bind:key' directives.解决办法_第1张图片

二、问题原因:Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的。

三、解决方法:

1> 更改vetur配置

位置:vscode->首选项->设置->搜索(vetur)

vscode提示Elements in iteration expect to have 'v-bind:key' directives.解决办法_第2张图片

2> 添加key

vscode提示Elements in iteration expect to have 'v-bind:key' directives.解决办法_第3张图片

你可能感兴趣的:(vscode提示Elements in iteration expect to have 'v-bind:key' directives.解决办法)