vue中提示$index is not defined
今天学习Vue中遇到了一个报错信息:$index is not defined,是我写了个for循环在HTML中,然后是因为版本的问题下面是解决方法:原来的是 v-for="person in items" v-on:click="deletePerson($index)"//这个仅仅适用于1.0版本,不要采坑了同学们这个在Vue1.0版本中式
·
今天学习Vue中遇到了一个报错信息:$index is not defined,是我写了个for循环在HTML中,然后是因为版本的问题
下面是解决方法:
原来的是 v-for="person in items"
v-on:click=
"deletePerson($index)"//这个仅仅适用于1.0版本,不要采坑了同学们
在Vue 2.0版本中获取索引我们需要通过 v-for = "(person ,index) in items ", 点击事件我们也不能使用$index,应该使用
v-on:click=
"deletePerson(index)"
更多推荐
已为社区贡献14条内容
所有评论(0)