javascript - vue.js methods 调用函数 参数 not defined
本文介绍了javascript - vue.js methods 调用函数 参数 not defined的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
<li v-for='item in title' v-text="item.name" :class="{aside:item.iscur}" v-on:click="setCur($index)">{{ item.name }}</li>
data:{
title:[
{name:'买入',id:'0',iscur:true},
{name:'卖出',id:'1',iscur:false},
{name:'Push',id:'2',iscur:false},
{name:'抵押',id:'3',iscur:false},
{name:'交易',id:'4',iscur:false},
]}
methods:{
setCur: function (index) {
index.currentTarget;
this.title.map(function (v,i) {
i==index? v.iscur=true: v.iscur=false;
});
}
}
vue.js methods 调用函数 $index is not defined
解决方案
vue2?
index-and-key-移除
改成类似
v-for="(item, index) in items"
这种样子的吧
这篇关于javascript - vue.js methods 调用函数 参数 not defined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文