<template>
    <div>
       <div v-for='(item,index) in arr' 
            v-bind:class='{bg:index==isactive}'
            @click='fn(index)'>
            {{item}}
       </div>
    </div>
  </template>
   
  <script>
    export default {
      data() {
        return {
             isactive:0,
             arr:['111','222','333','444']
        }
      },
      methods: {
        fn:function(index){
            console.log(index);
            this.isactive=index;
        }
      },
    }
  </script>
   
  <style scoped>
    /*点击文字变颜色*/
    .bg{
        color:pink;
    }
  </style>
   

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2021-08-08
  • 2021-03-25
  • 2021-06-20
相关资源
相似解决方案