Article From:https://segmentfault.com/q/1010000012141713

<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':''">Set the default < /button>< button class= "textright cancel-btn" v-popover:popover> unbound < /buttOn>< /div>< /li>< /ul>SetDefault () {Var self = this;$('.accountlis)T').On ('Click','.default-btn', function ()) {Var curli = $(this).Parents ('li');$('.accountl)Ist').Prepend (curli);Var curliIndex = curli.index ();Console.log (curliIndex); //curliIndexThe current subscript clicks on any one of the Li to be 0 subscriptPost (self, api.setDefault, self.setDefaultList, (response) => {Self.gEtEntBank ();})});},

Answer 0:

You combine this jQuery with Vue…
You can write the method directly in the methods of Vue, print index directly, read more API, and set the template.

Answer 1:
<li v-for="(item,index) in bankcardData" :key="index" @click="liClick(index)" :class="curindex === index ? 'active' : ''">

You have been programming with the idea of JQ all the time.

this.curindex === index;
console.log(index)//Getting the index of the Li is the subscript}

Leave a Reply

Your email address will not be published. Required fields are marked *