您好,登錄后才能下訂單哦!
這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)怎么在微信小程序中實(shí)現(xiàn)頂部導(dǎo)航特效,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
1.swiperTab.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)聽用戶下拉動(dòng)作 }, onReachBottom: function () { // 頁面上拉觸底事件的處理函數(shù) }, onShareAppMessage: function () { // 用戶點(diǎn)擊右上角分享 return { title: 'title', // 分享標(biāo)題 desc: 'desc', // 分享描述 path: 'path' // 分享路徑 } } })
2.swiperTab.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>
3.swiperTab.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; }
上述就是小編為大家分享的怎么在微信小程序中實(shí)現(xiàn)頂部導(dǎo)航特效了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。