Vue.js Vue v3预期为';v-bind:key';指令使用由';v代表';指示
编辑:我用parantheses修复了这个错误,将v-for改为global.base_colors中的Vue.js Vue v3预期为';v-bind:key';指令使用由';v代表';指示,vue.js,Vue.js,编辑:我用parantheses修复了这个错误,将v-for改为global.base_colors中的v-for=“(颜色,索引)” 为了学习,我正在开发我的第一个Vue(v3)应用程序 作为一个页面,使用Vue.createApp(),它工作得很好,但我一直在迁移它 我一直在犯这个错误 for(let color, index in global.base_colors); | ^ vue/no-parsing-error 226:60
v-for=“(颜色,索引)”
为了学习,我正在开发我的第一个Vue(v3)应用程序
作为一个页面,使用Vue.createApp()
,它工作得很好,但我一直在迁移它
我一直在犯这个错误
for(let color, index in global.base_colors);
| ^ vue/no-parsing-error
226:60 error Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive
从这个代码
<span v-for="color, index in global.base_colors" v-bind:key="color">
<input type="checkbox" :id="'inColor'+index" name="inColors" :value="color.toLowerCase()" class="gui"><label :for="'inColor'+index" :style="'border-left-color: '+color.toLowerCase()+'; background-color: '+color.toLowerCase()">{{color}}</label>
</span>
{{color}}
Mysite.global.base_colors
一个简单的字符串数组['red'、'blue'、'green']
有趣的是,代码是有效的。我可以看到错误覆盖后面的颜色列表正在渲染
当我搜索这个时,我得到的是迭代中
元素的页面,希望有'v-bind:key'指令
我用parantises修复了这个错误,将v-for改为v-for=“(颜色,索引)在global.base_colors中”