前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >微信小程序----导航栏选项卡(MUI顶部选项卡)

微信小程序----导航栏选项卡(MUI顶部选项卡)

作者头像
Rattenking
发布2021-02-01 11:12:13
1.6K0
发布2021-02-01 11:12:13
举报
文章被收录于专栏:Rattenking

效果图

导航栏选项卡效果图
导航栏选项卡效果图

WXML

代码语言:javascript
复制
<import src="../../template/list.wxml"/>

<view class="tui-tabbar-content">
  <view class="tui-tabbar-group">
    <text data-id="0" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 0 ? 'tui-active' : ''}}">已获得赏金</text>
    <text data-id="1" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 1 ? 'tui-active' : ''}}">赏金在路上</text>
    <text data-id="2" bindtap="changeTabbar" class="tui-tabbar-cell {{index == 2 ? 'tui-active' : ''}}">邀请失败</text>
  </view>
</view>
<view class="tui-list-box {{index == 0 ? '' : 'tui-hide'}}">
  <template wx:for="{{['选项卡一子选项 - 1','选项卡一子选项 -  2','选项卡一子选项 - 3','选项卡一子选项 - 4','选项卡一子选项 - 5','选项卡一子选项 - 6','选项卡一子选项 - 7','选项卡一子选项 - 8']}}" is="listNoneOnly" data="{{item}}"></template>
</view>
<view class="tui-list-box {{index == 1 ? '' : 'tui-hide'}}">
  <template wx:for="{{['选项卡二子选项 - 1','选项卡二子选项 -  2','选项卡二子选项 - 3','选项卡二子选项 - 4','选项卡二子选项 - 5']}}" is="listNoneOnly" data="{{item}}"></template>
</view>
<view class="tui-list-box {{index == 2 ? '' : 'tui-hide'}}">
  <template wx:for="{{['选项卡三子选项 - 1','选项卡三子选项 -  2','选项卡三子选项 - 3']}}" is="listNoneOnly" data="{{item}}"></template>
</view>

WXSS

代码语言:javascript
复制
page{background-color: #efeff4;}
.tui-tabbar-content{
  padding: 10px;
}
.tui-tabbar-group{
  border: 1px solid #4cd964;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
  display: table;
  table-layout: fixed;
  color: #4cd964;
}
.tui-tabbar-cell{
  display: table-cell;
  width: 100%;
  height: 80rpx;
  line-height: 80rpx;
  font-size: 35rpx;
  text-align: center;
}
.tui-tabbar-cell:not(:last-child){border-right: 1px solid #4cd964;}
.tui-tabbar-cell.tui-active{background-color: #4cd964;color: #fff;}

.tui-list-box{border-top:1px solid #c8c7cc;}

JS

代码语言:javascript
复制
Page({
  data: {
    index: 0
  },
  changeTabbar(e){
    this.setData({ index: e.currentTarget.dataset.id})
  }
})

总结

微信小程序的切换,采用的是对某一个值的判断,来对列表和tab bar进行切换!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017/12/29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 效果图
  • WXML
  • WXSS
  • JS
  • 总结
相关产品与服务
云开发 CloudBase
云开发(Tencent CloudBase,TCB)是腾讯云提供的云原生一体化开发环境和工具平台,为200万+企业和开发者提供高可用、自动弹性扩缩的后端云服务,可用于云端一体化开发多种端应用(小程序、公众号、Web 应用等),避免了应用开发过程中繁琐的服务器搭建及运维,开发者可以专注于业务逻辑的实现,开发门槛更低,效率更高。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档