2021-04-02

Tab栏切换

我们做tab栏的时候会有图标也要随着改变。(上下图标)

<div class="tabs">
          <div
            v-for="(item, index) in tabList"
            :key="index"
            :class="['tab-box', currentIndex == index ? 'active' : '']"
            @click="change(index)"
          >
            {{$t(item.label)}}
            <span style="float: right; margin-right: 20px;">
              <img src="../../assets/unfold.svg" alt="" v-show="currentIndex!=index">
            </span>
             <span style="float: right; margin-right: 20px;">
              <img src="../../assets/close.svg" alt="" v-show="currentIndex==index">
            </span>
          </div>
        </div>
.tabs {
  display: flex;
  justify-content: space-between;
  margin: 30px 0px;
  .tab-box {
    float: left;
    width: 560px;
    height: 56px;
    border-radius: 4px;
    border: 1px solid #cccccc;
    font-size: 18px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #334164;
    line-height: 3;
    padding-left: 20px;
  }
}
.active {
  background: #f08c1b;
  color: #fff !important;
}
 data() {
    return {
      currentIndex: 0,
      flag: false,
      tabList: [
        { label: "serveP.label1"
        },
        { label: "serveP.label2"
        }
      ],
    };
  },
  methods: {
    change: function (index) {
      this.currentIndex = index;
    },
  },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值