微信小程序中頂部導(dǎo)航欄的實(shí)現(xiàn)代碼
更新時(shí)間:2017年03月30日 14:44:53 投稿:lqh
這篇文章主要介紹了微信小程序中頂部導(dǎo)航欄的實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下
微信小程序中頂部導(dǎo)航欄的實(shí)現(xiàn)
實(shí)例代碼:
<view class="swiper-tab"> <view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">11</view> <view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">22</view> <view class="swiper-tab-list {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">33</view> <view class="swiper-tab-list {{currentTab==3 ? 'on' : ''}}" data-current="3" bindtap="swichNav">44</view> <view class="swiper-tab-list {{currentTab==4 ? 'on' : ''}}" data-current="4" bindtap="swichNav">55</view> </view> <swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 31}}px" bindchange="bindChange"> <!-- 我是哈哈 --> <swiper-item> <view>我是哈哈</view> </swiper-item> <!-- 我是呵呵 --> <swiper-item> <view>我是呵呵</view> </swiper-item> <!-- 我是嘿嘿 --> <swiper-item> <view>我是嘿嘿</view> </swiper-item> <swiper-item> <view>我是嘿嘿</view> </swiper-item> <swiper-item> <view>我是嘿嘿</view> </swiper-item> </swiper>
.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; }
var app = getApp() Page( { data: { /** * 頁(yè)面配置 */ 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 }) } }, /** * 點(diǎn)擊分享 */ onShareAppMessage: function () { return { title: '裝逼小程序', path: '/page/user?id=123' } } })
感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
您可能感興趣的文章:
- 微信小程序教程系列之設(shè)置標(biāo)題欄和導(dǎo)航欄(7)
- 微信小程序 開(kāi)發(fā)之頂部導(dǎo)航欄實(shí)例代碼
- 詳解微信小程序設(shè)置底部導(dǎo)航欄目方法
- 微信小程序自定義頭部導(dǎo)航欄和導(dǎo)航欄背景圖片 navigationStyle問(wèn)題
- 微信小程序頂部導(dǎo)航欄滑動(dòng)tab效果
- 詳解微信小程序膠囊按鈕返回|首頁(yè)自定義導(dǎo)航欄功能
- 微信小程序自定義navigationBar頂部導(dǎo)航欄適配所有機(jī)型(附完整案例)
- 微信小程序?qū)崙?zhàn)之頂部導(dǎo)航欄(選項(xiàng)卡)(1)
- 微信小程序?qū)崿F(xiàn)左側(cè)滑動(dòng)導(dǎo)航欄
- 微信小程序?qū)崿F(xiàn)左側(cè)導(dǎo)航欄
相關(guān)文章
微信小程序之滾動(dòng)視圖容器的實(shí)現(xiàn)方法
這篇文章主要介紹了微信小程序之滾動(dòng)視圖容器的實(shí)現(xiàn)方法的相關(guān)資料,希望通過(guò)本文能幫助到大家,讓大家掌握這部分內(nèi)容,需要的朋友可以參考下2017-09-09apply?call?bind方法原理及使用場(chǎng)景示例詳解
這篇文章主要為大家介紹了apply&call&bind方法原理及使用場(chǎng)景示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08websocket心跳重連實(shí)現(xiàn)探索(npm:websocket-heartbeat-js)
這篇文章主要為大家介紹了websocket心跳重連實(shí)現(xiàn)探索(npm:websocket-heartbeat-js),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07