vue自定义标题切换带图片

vue项目常用到的标题切换,记录一下,方便下次使用
在这里插入图片描述

    <div class="part_title">
        <div class="change-con">
          <!-- 自定义切换 -->
          <p
            class="change"
            v-for="(v, index) in imgs"
            :key="index"
            @click="activeBtn(index)"
          >
            <img v-if="isActive == index" :src="v.urlAcitve" alt="" />
            <img v-else :src="v.url" alt="" />
            <span
              :style="{
                color: isActive == index ? '#EC830F' : '#999999',
              }"
              >{{ v.name }}</span
            >
            <span
              class="underline"
              :style="{
                display: isActive == index ? 'block' : 'none',
              }"
            >
              <el-divider direction="horizontal"></el-divider>
            </span>
          </p>
        </div>
      </div>
return:{
  data(){
    imgs: [
	        {
	          url: require("../../../public/web/icon_huiyuan.png"),
	          urlAcitve: require("../../../public/web/icon_zhifu.png"),
	          name: "支付",
	        },
	        {
	          url: require("../../../public/web/icon_huiyuan.png"),
	          urlAcitve: require("../../../public/web/icon_zhifu.png"),
	          name: "会员",
	        },
	        {
	          url: require("../../../public/web/icon_huiyuan.png"),
	          urlAcitve: require("../../../public/web/icon_zhifu.png"),
	          name: "安全",
	        },
	        {
	          url: require("../../../public/web/icon_huiyuan.png"),
	          urlAcitve: require("../../../public/web/icon_zhifu.png"),
	          name: "基础",
	        },
	        {
	          url: require("../../../public/web/icon_huiyuan.png"),
	          urlAcitve: require("../../../public/web/icon_zhifu.png"),
	          name: "营销",
	        },
      ],
      isActive: 0,
}}

	methods:{
	 activeBtn(val) {
	      console.log(val);
	      this.isActive = val;
	    },
	}



	.part_title {
	  width: 100%;
	  height: 106px;
	  filter: blur(0px);
	  background: #ffffff;
	}
	.change {
	  width: 106px;
	  height: 100%;
	  margin: 0 15px;
	  text-align: center;
	}
	.change img {
	  width: 36px;
	  height: 36px;
	  display: block;
	  margin: 0 auto;
	  margin-top: 18px;
	}
	.change span {
	  display: block;
	  margin: 8px 0;
	  font-size: 20px;
	  /* color: #ec830f; */
	}
	.change-con {
	  width: 1500px;
	  margin: 0 auto;
	  display: flex;
	  justify-content: center;
	}
	.change .underline {
	  width: 100%;
	}
	.underline > .el-divider--horizontal {
	  width: 100%;
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值