vue实现tab切换功能

9 篇文章 0 订阅
8 篇文章 0 订阅

vue实现tab选项卡功能

效果图

在这里插入图片描述

  <div class="study-title">
          <button @click="study1">寓教于乐</button>
          <button @click="study2">寓教于学</button>
          <button @click="study3">学以致用</button>
          <button @click="study4">勤学动脑</button>
        </div>
        <div class="study-content">
            <!-- 利用v-show来控制显示隐藏 -->
          <div
            class="study-item"
            v-show="imgs == 1"
          ></div>
          <div
            class="study-item2"
            v-show="imgs == 2"
          ></div>
          <div
            class="study-item3"
            v-show="imgs == 3"
          ></div>
          <div
            class="study-item4"
            v-show="imgs == 4"
          ></div>
</div>
data(){
    return{
        imgs : 1
}
},
methods:{
     study1() {
      this.imgs = 1;
    },
    study2() {
      this.imgs = 2;
    },
    study3() {
      this.imgs = 3;
    },
    study4() {
      this.imgs = 4;
    },
}
.study-title {
  width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
.study-title button {
  width: 210px;
  height: 70px;
  color: #fff;
  border: none;
  background: rgb(255, 150, 0);
  cursor: pointer;
  border-radius: 40px;
  font-size: 32px;
  line-height: 70px;
  box-shadow: 2px 2px 10px rgb(175, 175, 175);
}
.study-item,
.study-item2,
.study-item3,
.study-item4 {
  width: 1400px;
  height: 468px;
  margin: 0 auto;
  background-repeat: no-repeat;
  margin-top: 20px;
}
.study-item4 {
  background: url("../assets/1.png");
}
.study-item {
  background: url("../assets/2.png");
}
.study-item2 {
  background: url("../assets/3.png");
}
.study-item3 {
  background: url("../assets/4.png");
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值