【MpVue】v-for列表渲染踩坑记录-vscode

软件:VsCode

①Elements in iteration expect to have ‘v-bind:key’ directives.

<div v-for='item in todos'>
 {{ item.text }}
</div>

这个为什么会报错呢,网上搜集了一些资料才知道
VUE2.2+版本里面,当在组件中使用v-for时,key是必须的
来源:点这里

添加上去就好了

<div v-for='item in todos' :key="item.id">
  {{ item.text }}
</div>

②*** is defined but never used.eslint-plugin-vue

英文意思: 已被定义但从未被使用(is defined but never)

不管是vue也好,小程序也好默认的索引值都是index
然而官方文档指出:
【MpVue】v-for列表渲染踩坑记录-vscode_第1张图片
实际上手:

【MpVue】v-for列表渲染踩坑记录-vscode_第2张图片
原因:没有用到index(is defined but never
在这里插入图片描述

你可能感兴趣的:(Vue/MpVue)