<template>
  //v-for循环出来多个按钮,便于获取index
        <span v-for="(item,index) in list" :key="index"   @click="countAuth(index)"  :class="{selected:index==current}">
  </span>
</template>
export default{
  data(){
    return{
      list:["第一个按钮","第二个按钮","第三个按钮","第四个按钮"],
      current:0     //自定义属性,便于传递index
    }
  },
  methods:{
    countAuth(index){
      this.current=index   //传递
    }
  }
}
<style scoped>
selected{
  color:red
}
<style>

相关文章:

  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2023-03-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案