微信小程序 swiper制作tab切換實(shí)現(xiàn)附源碼
微信小程序 swiper制作tab切換
實(shí)現(xiàn)效果圖:
swiper制作tab切換
index.html
<view class="swiper-tab"> <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">Seside1</view> <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">Seside2</view> <view class="swiper-tab-list {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">Seside3</view> </view> <swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 31}}px" bindchange="bindChange"> <swiper-item> <view>Seside1</view> </swiper-item> <swiper-item> <view>Seside2</view> </swiper-item> <swiper-item> <view>Seside3</view> </swiper-item> </swiper>
index.css
.swiper-tab{ width: 100%; border-bottom: 2rpx solid #777777; text-align: center; line-height: 80rpx; } .swiper-tab-list{ font-size: 30rpx; display: inline-block; width: 20%; color: #777777; } .on{ color: #da7c0c; border-bottom: 5rpx solid #da7c0c; } .swiper-box{ display: block; height: 100%; width: 100%; overflow: hidden; } .swiper-box view{ text-align: center; }
index.js
//index.js //獲取應(yīng)用實(shí)例 var app = getApp() Page( { data: { // 頁面配置 winWidth: 0, winHeight: 0, // tab切換 currentTab: 0, }, onLoad: function() { var that = this; // 獲取系統(tǒng)信息 wx.getSystemInfo( { success: function( res ) { that.setData( { winWidth: res.windowWidth, winHeight: res.windowHeight }); } }); }, // 滑動(dòng)切換tab bindChange: function( e ) { var that = this; that.setData( { currentTab: e.detail.current }); }, // 點(diǎn)擊tab切換 swichNav: function( e ) { var that = this; if( this.data.currentTab === e.target.dataset.current ) { return false; }else{ that.setData( { currentTab: e.target.dataset.current }) } } })
源碼下載:http://xiazai.jb51.net/201701/yuanma/tabdemo03(jb51.net).rar
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
- 微信小程序開發(fā)之實(shí)現(xiàn)選項(xiàng)卡(窗口頂部TabBar)頁面切換
- 微信小程序?qū)崿F(xiàn)tab左右切換效果
- 微信小程序 Tab頁切換更新數(shù)據(jù)
- 微信小程序開發(fā)之選項(xiàng)卡(窗口底部TabBar)頁面切換
- 微信小程序?qū)崿F(xiàn)tab切換效果
- 微信小程序滾動(dòng)Tab實(shí)現(xiàn)左右可滑動(dòng)切換
- 微信小程序?qū)崿F(xiàn)tab和swiper切換結(jié)合效果
- 微信小程序?qū)崿F(xiàn)tab頁面切換功能
- 微信小程序開發(fā)實(shí)現(xiàn)的選項(xiàng)卡(窗口頂部/底部TabBar)頁面切換功能圖文詳解
- 微信小程序?qū)崿F(xiàn)tab頁面切換效果
相關(guān)文章
JS開發(fā)Blob和FileReader構(gòu)造函數(shù)使用示例詳解
這篇文章主要為大家介紹了JS開發(fā)Blob和FileReader構(gòu)造函數(shù)使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08微信小程序request請(qǐng)求后臺(tái)接口php的實(shí)例詳解
這篇文章主要介紹了微信小程序request請(qǐng)求后臺(tái)接口php的實(shí)例詳解的相關(guān)資料,希望通過本文能幫助到大家,需要的朋友可以參考下2017-09-09Typescript類型系統(tǒng)FLOW靜態(tài)檢查基本規(guī)范
這篇文章主要為大家介紹了Typescript語言的類型系統(tǒng)FLOW靜態(tài)檢查基本規(guī)范,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05微信小程序 wxapp內(nèi)容組件 text詳細(xì)介紹
這篇文章主要介紹了微信小程序 wxapp內(nèi)容組件 text詳細(xì)介紹的相關(guān)資料,并附簡(jiǎn)單實(shí)例代碼,需要的朋友可以參考下2016-10-10微信小程序 詳解頁面跳轉(zhuǎn)與返回并回傳數(shù)據(jù)
這篇文章主要介紹了微信小程序 詳解頁面跳轉(zhuǎn)與返回并回傳數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2017-02-02