Switch focus class, non-v-for structure in vue

<ul>
  <li @click="getgamelist(1,10)"></li>
  <li @click="getgamelist(1,1)">1</li>
  <li @click="getgamelist(2,4)">2-4</li>
  <li @click="getgamelist(5,6)">5-6</li>
  <li @click="getgamelist(7,10)">7</li>
</ul>

with the above structure, you want to add class to the clicked li after click, and delete the corresponding class

.

I have searched for relevant solutions, and basically all of them are solved by getting index through v-for.

Jun.23,2021

v-for provides a way to abbreviate. His product is your way of writing, and you can't stop you if you don't want to dry,. Then you can remove the v-for part from what you find on the Internet, copy n, and turn the index into 0 answer n in order.


        <ul>
          <li @click="getgamelist(1,10);activeitem(1)" :class="curr === 1 ? 'active' : ''"></li>
          <li @click="getgamelist(1,1);activeitem(2)" :class="curr === 2 ? 'active' : ''">1</li>
          <li @click="getgamelist(2,4);activeitem(3)" :class="curr === 3 ? 'active' : ''">2-4</li>
          <li @click="getgamelist(5,6);activeitem(4)" :class="curr === 4 ? 'active' : ''">5-6</li>
          <li @click="getgamelist(7,10);activeitem(5)" :class="curr === 5 ? 'active' : ''">7</li>
        </ul>

html

activeitem(index) {
      index < 6 ? this.curr = index : this.curr2 = index
    }

these parameters can be judged by a reminder from a member of the discussion group.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3f4d1-2bbfb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3f4d1-2bbfb.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?