vue+elementUI实现点击按钮互斥效果

先看看实现的效果吧!

在这里插入图片描述

步骤:
一.html代码
<!-- 等级筛选 -->
    <div class="level-screening">
      <el-button
        size="medium"
        type="primary"
        :class="index==itemType?'highlight':''"
        v-for="(item,index) in levelList"
        :key="index"
        @click.prevent="materTay(index,item.code)"
      >
        {{ item.codeValue }}</el-button
      >
    </div>
二.css(less)代码
.level-screening {
      padding-left: 40px;
      box-sizing: border-box;
      height: 120px;
      text-align: left;
      line-height: 80px;
      .el-button {
        border-color: #0085f4;
        background-color: #fff;
        color: #0085f4;
      }
      .highlight {
        background-color: #8e66f6 !important;
        color: #fff;
      }
    }
三.js代码
export default {
 data() {
    return {
       levelList: [
        {
          code: '',
          codeValue: '全部'
        },
        {
          code: '',
          codeValue: '铜'
        },
        {
          code: '',
          codeValue: '银'
        },
        {
          code: '',
          codeValue: '金'
        },
        {
          code: '',
          codeValue: '白金'
        },
        {
          code: '',
          codeValue: '铂金'
        }
      ], // 等级筛选数据
      itemType: 0, // 等级筛选选中的标识
      materialCode: '' // 分类的code值
        }
    },
   methods: {
    // 等级筛选互斥效果
    materTay(itemType, code) {
      // 等级筛选选中的标识-高亮效果
      this.itemType = itemType
      // 分类的code值
      this.materialCode = code
    }
  }
}
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值