【WEEX】tab选项卡和轮播图结合

3 篇文章 0 订阅

效果截图:
在这里插入图片描述
在这里插入图片描述
代码展示:

<div class="tabbar">
     <!-- 选项卡下面的小条 -->
     <div class="tab-active active" :style="{ left: activeTab * 150 + 'px'}">
         <div class="tab-slide"></div>
     </div>
     //选项卡标题数据
     <div v-for="(tab, i) in tabs" :key="i" class="tab" @click="activeTab = i">
          <text :class="['tab-title',activeTab==i?'tab-checked':'']">{{tab.title}}</text>
     </div>
</div>
//选项卡内容
<slider class="tab-panels" :index="activeTab" @change="changeTab" infinite=false>
//选项卡对应的轮播图页面
     <div class="tab-frame"  v-for="(panel, pi) in tabs"  :key="pi">
     //对应页面的内容,可以自己自定义
         <div v-for="(name,index) in panel.cate" :key="index" @click="selectTag(index,name)">
            <text  :class="[selectCate==index?'tab-content-checked':'tab-content']">{{name}}</text>
            <image v-if="selectCate==index" class="tab-image-checked" src="https://w.bangbangce.com/static/wechat/Assets/Images/Public/bot_right.png"></image>
        </div>                        
     </div>
</slider>

样式代码:

.tabbar{
        flex-direction: row;
    }
    .tab-active{
        height: 100px;
        width: 150px;
        justify-content:flex-end ;
        align-items: center;
    }
    .tab-slide{
        height: 5px;
        width: 50px;
        border-radius: 10px;
        background-color: #01b2b6;

    }
    .tab{
        height: 120px;
        width: 150px;
        justify-content: center;
        align-items: center;
    }
    .active {
        position: absolute;
        top: 0;
        left: 0;
        transition: left 0.2s ease-in-out;
    }
    .tab-title{
        font-size: 30px;
    }
    .tab-checked{
        color: #01b2b6;
    }
    .tab-panels {
        position: relative;
        width: 700px;
        flex: 1;
        transition: left 0.2s ease-in-out;
        margin-right: 10px;
        margin-left: 10px;
    }
    .tab-frame{
        flex-direction: row;
        flex-wrap: wrap;
    
    }
    
    .tab-content{
        font-size: 35px;
        color: #ffffff;
        background-color: #01b2b6;
        border-color: #01b2b6;
        border-width: 3px;
        border-radius: 10px;
        padding-top: 20px;
        padding-bottom: 20px;
        padding-left: 15px;
        padding-right: 15px;
        margin-right: 10px;
        margin-left: 10px;
        margin-bottom: 10px;
        margin-top: 10px;
    }
    .tab-content-checked{
        font-size: 35px;
        color: #01b2b6;
        border-color: #01b2b6;
        border-width: 3px;
        border-radius: 10px;
        padding-top: 20px;
        padding-bottom: 20px;
        padding-left: 15px;
        padding-right: 15px;
        margin-right: 10px;
        margin-left: 10px;
        margin-bottom: 10px;
        margin-top: 10px;

    }
    .tab-image-checked{
        width: 30px;
        height: 30px;
        border-bottom-right-radius: 5px;
        position: absolute;
        right: 13px;
        bottom: 13px;
    }

数据格式(可以自己随便定义):

 tabs:[
         {"title":"预测","cate":["随便","自定义"]},
         {"title":"大运","cate":["很好","不错",""]}
     ],

完结撒花~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值