本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)MUI頂部選項(xiàng)卡的具體代碼,供大家參考,具體內(nèi)容如下
DEMO下載
效果圖
WXML
<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="{{['選項(xiàng)卡一子選項(xiàng) - 1','選項(xiàng)卡一子選項(xiàng) - 2','選項(xiàng)卡一子選項(xiàng) - 3','選項(xiàng)卡一子選項(xiàng) - 4','選項(xiàng)卡一子選項(xiàng) - 5','選項(xiàng)卡一子選項(xiàng) - 6','選項(xiàng)卡一子選項(xiàng) - 7','選項(xiàng)卡一子選項(xiàng) - 8']}}" is="listNoneOnly" data="{{item}}"></template> </view> <view class="tui-list-box {{index == 1 ? '' : 'tui-hide'}}"> <template wx:for="{{['選項(xiàng)卡二子選項(xiàng) - 1','選項(xiàng)卡二子選項(xiàng) - 2','選項(xiàng)卡二子選項(xiàng) - 3','選項(xiàng)卡二子選項(xiàng) - 4','選項(xiàng)卡二子選項(xiàng) - 5']}}" is="listNoneOnly" data="{{item}}"></template> </view> <view class="tui-list-box {{index == 2 ? '' : 'tui-hide'}}"> <template wx:for="{{['選項(xiàng)卡三子選項(xiàng) - 1','選項(xiàng)卡三子選項(xiàng) - 2','選項(xiàng)卡三子選項(xiàng) - 3']}}" is="listNoneOnly" data="{{item}}"></template> </view>
WXSS
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
Page({ data: { index: 0 }, changeTabbar(e){ this.setData({ index: e.currentTarget.dataset.id}) } })
總結(jié)
微信小程序的切換,采用的是對某一個(gè)值的判斷,來對列表和tab bar進(jìn)行切換!
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com