ESLint: 'v-for' directives require that attribute value. (vue/valid-v-for)

头像
码农笔录
2019-04-04阅读 5828

vue 2.2+ 版本要求v-for 循环的时候,必须要给key赋值,否则会报如下的错


ESLint: 'v-for' directives require that attribute value. (vue/valid-v-for)

'v-bind:key' directive to use the variables which are defined by the 'v-for' directive (vue/valid-v-for)  


解决办法当然是给他绑定一个key了,循环的时候可以返回当前的下标index,我们就把下标赋值给key