這篇文章給大家分享的是有關(guān)小程序中怎么實現(xiàn)頂部tab切換以及滑動切換時導(dǎo)航欄會隨著移動的效果的內(nèi)容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
成都創(chuàng)新互聯(lián)公司長期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團隊從業(yè)經(jīng)驗10年,關(guān)注不同地域、不同群體,并針對不同對象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺,與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為永定企業(yè)提供專業(yè)的網(wǎng)站制作、成都網(wǎng)站制作,永定網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗和眾多成功案例,為您定制開發(fā)。實現(xiàn)的效果:
js:
Page({ data: { // tab切換 currentTab: 0, }, swichNav: function (e) { console.log(e); var that = this; if (this.data.currentTab === e.target.dataset.current) { return false; } else { that.setData({ currentTab: e.target.dataset.current, }) } }, swiperChange: function (e) { console.log(e); this.setData({ currentTab: e.detail.current, }) }, onLoad: function (options) { // 生命周期函數(shù)--監(jiān)聽頁面加載 }, onReady: function () { // 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成 }, onShow: function () { // 生命周期函數(shù)--監(jiān)聽頁面顯示 }, onHide: function () { // 生命周期函數(shù)--監(jiān)聽頁面隱藏 }, onUnload: function () { // 生命周期函數(shù)--監(jiān)聽頁面卸載 }, onPullDownRefresh: function () { // 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動作 }, onReachBottom: function () { // 頁面上拉觸底事件的處理函數(shù) }, onShareAppMessage: function () { // 用戶點擊右上角分享 return { title: 'title', // 分享標題 desc: 'desc', // 分享描述 path: 'path' // 分享路徑 } } })
wxml:
<view class="page"> <!--頂部導(dǎo)航欄--> <view class="swiper-tab"> <view class="tab-item {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">Tab1</view> <view class="tab-item {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">Tab2</view> <view class="tab-item {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">Tab3</view> </view> <!--內(nèi)容主體--> <swiper class="swiper" current="{{currentTab}}" duration="200" bindchange="swiperChange"> <swiper-item> <view>我是tab1</view> </swiper-item> <swiper-item> <view>我是tab2</view> </swiper-item> <swiper-item> <view>我是tab3</view> </swiper-item> </swiper> </view>
wxss:
.page { margin-left: 10rpx; margin-right: 10rpx; } .swiper-tab { display: flex; flex-direction: row; line-height: 80rpx; border-bottom: 2rpx solid #777; } .tab-item { width: 33.3%; text-align: center; font-size: 15px; color: #777; } .swiper { height: 1100px; background: #dfdfdf; } .on { color: blue; border-bottom: 5rpx solid blue; }
感謝各位的閱讀!關(guān)于“小程序中怎么實現(xiàn)頂部tab切換以及滑動切換時導(dǎo)航欄會隨著移動的效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
當前名稱:小程序中怎么實現(xiàn)頂部tab切換以及滑動切換時導(dǎo)航欄會隨著移動的效果-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://www.rwnh.cn/article30/cedcpo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計、App開發(fā)、虛擬主機、企業(yè)網(wǎng)站制作、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容