vue-click to switch styles

<div class="radio-div" v-for="(item,index) of bjtjRadio" :key="index"
  @click="bjtjChangeValue(index)">
  <span class="radio"><span :class="{liang:index===activeRadio}"></span></span>
  <span>{
    
    {
    
    item.text}}</span>
</div>
                    
data () {
    
    
    return {
    
    
      activeRadio: 0,
      bjtjRadio: [
        {
    
    
          id: 'suoyou',
          text: '所有'
        },
        {
    
    
          id: 'huojing',
          text: '火警'
        },
        {
    
    
          id: 'tongdao',
          text: '通道'
        }
     ]

methods: {
    
    
   bjtjChangeValue (index) {
    
     // 报警统计切换
     this.activeRadio = index
   }

Guess you like

Origin blog.csdn.net/yuyu_2019/article/details/110384712