vue使用v-for时vscode报错 Elements in iteration expect to have v-bind key directives

错误提示

[vue-language-server] Elements in iteration expect to have 'v-bind:key' directives.
Renders the element or template block multiple times based on the source data

解决

在v-for 后添加 :key=‘item’

<li v-for="i in list" :key="i">
<div class="item" v-for="(user,index) in datalist" :key='index' >

原因

Vue 2.2.0+的版本里,当在组件中使用v-for时,key是必须的

参考文献

https://www.cnblogs.com/zdz8207/p/vue-for-v-bind-key.html

https://blog.csdn.net/qq_43540219/article/details/107615142

上一篇:云会让DBA失业吗?分布式数据库学习路径、CAP理论?OLAP/OLTP & MPP/SMP


下一篇:Linux命令