<ul class="accountlist"> <li v-for="(item,index) in bankcardData" :key="index" @click="curindex === index" :class="curindex === index ? 'active' : ''"> <i class="icon-corner corner" v-if="curindex === index"></i> <span class="textcenter">{{item.bankName}}</span> <p class="card-number textleft">{{item.accountNo}}</p> <div class="anchor"> <button class="textleft btn default-btn" @click="activestyle($event,index)" :class="curindex === index?'opacity':''">设置默认</button> <button class="textright cancel-btn" v-popover:popover>解除绑定</button> </div> </li></ul>setDefault(){ var self = this; $('.accountlist').on('click', '.default-btn', function() { var curli = $(this).parents('li'); $('.accountlist').prepend(curli); var curliIndex = curli.index(); console.log(curliIndex); //curliIndex 当前下标 点击任何一个li都为 0下标 post(self,api.setDefault,self.setDefaultList,(response)=>{ self.getEntBank(); }) });},
1 回答
梦里花落0921
TA贡献1772条经验 获得超6个赞
<li v-for="(item,index) in bankcardData" :key="index" @click="liClick(index)" :class="curindex === index ? 'active' : ''">
赶脚你还一直再用jq的思想在编程,
liClick(index){
this.curindex === index;
console.log(index)//获取li 的 index即下标
}
添加回答
举报
0/150
提交
取消