這篇文章給大家分享的是有關(guān)小程序中怎么實(shí)現(xiàn)頂部tab切換以及滑動(dòng)切換時(shí)導(dǎo)航欄會(huì)隨著移動(dòng)的效果的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。
成都創(chuàng)新互聯(lián)公司長(zhǎng)期為上1000家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開(kāi)放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為永定企業(yè)提供專(zhuān)業(yè)的網(wǎng)站制作、成都網(wǎng)站制作,永定網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開(kāi)發(fā)。實(shí)現(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)聽(tīng)頁(yè)面加載 }, onReady: function () { // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面初次渲染完成 }, onShow: function () { // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面顯示 }, onHide: function () { // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面隱藏 }, onUnload: function () { // 生命周期函數(shù)--監(jiān)聽(tīng)頁(yè)面卸載 }, onPullDownRefresh: function () { // 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽(tīng)用戶下拉動(dòng)作 }, onReachBottom: function () { // 頁(yè)面上拉觸底事件的處理函數(shù) }, onShareAppMessage: function () { // 用戶點(diǎn)擊右上角分享 return { title: 'title', // 分享標(biāo)題 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)于“小程序中怎么實(shí)現(xiàn)頂部tab切換以及滑動(dòng)切換時(shí)導(dǎo)航欄會(huì)隨著移動(dòng)的效果”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
當(dāng)前名稱(chēng):小程序中怎么實(shí)現(xiàn)頂部tab切換以及滑動(dòng)切換時(shí)導(dǎo)航欄會(huì)隨著移動(dòng)的效果-創(chuàng)新互聯(lián)
轉(zhuǎn)載注明:http://vcdvsql.cn/article30/cedcpo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)、App開(kāi)發(fā)、虛擬主機(jī)、企業(yè)網(wǎng)站制作、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容