tab切换适用于H5和PC不借助组件

tab切换适用于H5和PC不借助任何组件



前言

以下就是今天要讲的内容,本文仅仅简单介绍了自己经常在项目会用到tab切换,但是又不想组件,所以就自己做了一个,希望对看到的同行有帮助。


提示:以下是本篇文章正文内容,下面案例可供参考使用
在这里插入图片描述

一、代码步骤

代码如下(示例):

 <!--tab-->
    <div>
      <ul class="tabsbox">
        <li @click="cur = 0" :class="{ active: cur == 0 }">实物信息</li>
        <li @click="cur = 1" :class="{ active: cur == 1 }">技术信息</li>
        <li @click="cur = 2" :class="{ active: cur == 2 }">中国准则</li>
        <li @click="cur = 3" :class="{ active: cur == 3 }">税务准则</li>
        <li @click="cur = 4" :class="{ active: cur == 4 }">其他信息</li>
      </ul>
      <div class="tab-contents">
        <div v-show="cur == 0">实物信息</div>
        <div v-show="cur == 1">技术信息</div>
        <div v-show="cur == 2">中国准则</div>
        <div v-show="cur == 3">税务准则</div>
        <div v-show="cur == 4">其他信息</div>
      </div>
    </div>
		 data() {
		    //这里存放数据
		    return {
		      cur: 0,//初始值
		    };
		  },
		  <style  scoped>
		  /* tab栏切换 */
.tabsbox {
  overflow: hidden;
  margin-top: 10px;
}
.tabsbox > li {
  float: left;
  width: 20%;
  background: #fff;
  text-align: center;
  border-bottom: 1.5px solid #e5e5e5;
  font-size: 12px;
  line-height: 50px;
  border-bottom: 1.5px solid transparent;
}
.tabsbox>li.active {
  /* color: #E93637; */
  border-bottom: 3px solid #e93637;
}
.tab-contents {
  margin-top: 10px;
  width: 100%;
  height: 300px;
  background: #fff;
  padding: 12px;
  margin-bottom: 60px;
}
</style>

总结

以上就是今天要讲的内容,本文仅仅简单介绍了自己经常在项目会用到,但是又不想组件,所以就自己做了一个,希望对看到的同行有帮助
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

奥佳博客(王小政)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值