亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序?qū)崿F(xiàn)頂部導(dǎo)航特效

 更新時(shí)間:2019年01月28日 14:46:04   作者:BlochCoding  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)頂部導(dǎo)航特效,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)頂部導(dǎo)航的具體代碼,供大家參考,具體內(nèi)容如下

之前Android開發(fā)時(shí),頂部導(dǎo)航用到viewPage,微信小程序里想要達(dá)到同樣的效果,可用swiper來(lái)實(shí)現(xiàn),先看效果圖


上代碼:

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)聽頁(yè)面加載
  },
  onReady: function () {
    // 生命周期函數(shù)--監(jiān)聽頁(yè)面初次渲染完成
  },
  onShow: function () {
    // 生命周期函數(shù)--監(jiān)聽頁(yè)面顯示
  },
  onHide: function () {
    // 生命周期函數(shù)--監(jiān)聽頁(yè)面隱藏
  },
  onUnload: function () {
    // 生命周期函數(shù)--監(jiān)聽頁(yè)面卸載
  },
  onPullDownRefresh: function () {
    // 頁(yè)面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作
  },
  onReachBottom: function () {
    // 頁(yè)面上拉觸底事件的處理函數(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;
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論