html代码

<div v-for="(item,index) of 数组名" :key="index" :class="active==index ? 'activeClass' : '  ' ">

      <div @click="change(index)" ></div>

</div>

js代码

export default {

    data() {

       return { //默认选中第一个 active:0 }

         },

      methods:{

        change(){ //把index值赋给active,点击改变样式 this.active=index; }

       }

}

css代码

.activeClass{ color:#ca151e; border: 1px solid #ca151e; }

本文引于https://blog.csdn.net/weixin_41599291/article/details/92825484,谢谢作者

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-12-26
  • 2022-12-23
  • 2021-12-11
猜你喜欢
  • 2021-10-12
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
相关资源
相似解决方案