最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動條不顯示的方法示例

 更新時間:2018年12月20日 09:55:39   作者:CoKeny  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動條不顯示的方法,涉及微信小程序swiper選項卡組件相關(guān)操作技巧,需要的朋友可以參考下

本文實例講述了微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動條不顯示的方法。分享給大家供大家參考,具體如下:

index.wxml文件:

<view class="swiper-tab">
 <view class="swiper-tab-item {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">為你推薦</view>
 <view class="swiper-tab-item {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">新品上架</view>
 <view class="swiper-tab-item {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">最熱商品</view>
</view>
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{clientHeight?clientHeight-'40'+'px':'auto'}}" bindchange="bindChange" >
 <swiper-item>
 <scroll-view scroll-y="{{true}}" style="height: {{clientHeight?clientHeight+'px':'auto'}}">
  <view style='height:200px'>為你推薦</view>
  <view style='height:200px'>為你推薦</view>
  <view style='height:200px'>為你推薦</view>
  <view style='height:200px'>為你推薦</view>
  <view style='height:200px'>為你推薦</view>
 </scroll-view>
 </swiper-item>
 <swiper-item>
  <view>新品上架</view>
 </swiper-item>
 <swiper-item>
  <view>最熱商品</view>
 </swiper-item>
</swiper>

index.wxss文件:

/**index.wxss**/
.userinfo {
 display: flex;
 flex-direction: column;
 align-items: center;
}
.userinfo-avatar {
 width: 128rpx;
 height: 128rpx;
 margin: 20rpx;
 border-radius: 50%;
}
.userinfo-nickname {
 color: #aaa;
}
.usermotto {
 margin-top: 200px;
}
.swiper-tab {
 width: 100%;
 text-align: center;
 line-height: 80rpx;
 margin-top:10rpx;
 margin-bottom: 20rpx;
}
.swiper-tab-item {
 font-size: 30rpx;
 display: inline-block;
 width: 33.33%;
 color: #666;
}
.on {
 color: #FEA611;
 border-bottom: 5rpx solid #FEA611;
}
.swiper-box {
 display: block;
 height: 100%;
 width: 100%;
 overflow: hidden;
}
.swiper-box view {
 text-align: center;
}

index.js文件:

//獲取應(yīng)用實例
const app = getApp()
Page({
 data: {
  motto: 'Hello World',
  userInfo: {},
  hasUserInfo: false,
  canIUse: wx.canIUse('button.open-type.getUserInfo'),
  clientWidth: 0,
  clientHeight: 0,
  // tab切換
  currentTab: 0
 },
 //事件處理函數(shù)
 bindViewTap: function () {
  wx.navigateTo({
   url: '../logs/logs'
  })
 },
 onLoad: function () {
  var that = this;
  wx.getSystemInfo({
   success: function (res) {
    that.setData({
     clientHeight: res.windowHeight
    });
   }
  });
  if (app.globalData.userInfo) {
   this.setData({
    userInfo: app.globalData.userInfo,
    hasUserInfo: true
   })
  } else if (this.data.canIUse) {
   // 由于 getUserInfo 是網(wǎng)絡(luò)請求,可能會在 Page.onLoad 之后才返回
   // 所以此處加入 callback 以防止這種情況
   app.userInfoReadyCallback = res => {
    this.setData({
     userInfo: res.userInfo,
     hasUserInfo: true
    })
   }
  } else {
   // 在沒有 open-type=getUserInfo 版本的兼容處理
   wx.getUserInfo({
    success: res => {
     app.globalData.userInfo = res.userInfo
     this.setData({
      userInfo: res.userInfo,
      hasUserInfo: true
     })
    }
   })
  }
 },
 getUserInfo: function (e) {
  console.log(e)
  app.globalData.userInfo = e.detail.userInfo
  this.setData({
   userInfo: e.detail.userInfo,
   hasUserInfo: true
  })
 },
 bindChange: function (e) {
  var that = this;
  that.setData({ currentTab: e.detail.current });
 },
 swichNav: function (e) {
  var that = this;
  if (this.data.currentTab === e.target.dataset.current) {
   return false;
  } else {
   that.setData({
    currentTab: e.target.dataset.current
   })
  }
 }
})

希望本文所述對大家微信小程序開發(fā)有所幫助。

相關(guān)文章

  • JS數(shù)組在內(nèi)存中的效率問題淺析

    JS數(shù)組在內(nèi)存中的效率問題淺析

    用js有很久了,但都沒有深究過js的數(shù)組形式,下面這篇文章主要給大家介紹了關(guān)于JS數(shù)組在內(nèi)存中的效率問題,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-02-02
  • 低代碼從0到1創(chuàng)建小程序項目詳解流程

    低代碼從0到1創(chuàng)建小程序項目詳解流程

    低代碼作為開發(fā)工具類的產(chǎn)品,需要有從0到1體系化的教程才可以,而且還得有教師進行輔助。否則,學(xué)習(xí)低代碼是有難度的,入門很難。因為大家習(xí)慣了用代碼編程,一下子過度到可視化編程,有一個思路上的轉(zhuǎn)變
    2022-08-08
  • es6中使用map簡化復(fù)雜條件判斷操作實例詳解

    es6中使用map簡化復(fù)雜條件判斷操作實例詳解

    這篇文章主要介紹了es6中使用map簡化復(fù)雜條件判斷操作,結(jié)合實例形式詳細(xì)分析了傳統(tǒng)方法與map簡化復(fù)雜條件判斷的相關(guān)操作技巧,需要的朋友可以參考下
    2020-02-02
  • 在JS方法中返回多個值的方法匯總

    在JS方法中返回多個值的方法匯總

    本文給大家匯總了在javascript方法中返回多個值的方法,都是在個人項目中檢驗過的,這里推薦給大家,有需要的小伙伴可以參考下。
    2015-05-05
  • js實現(xiàn)兼容IE6與IE7的DIV高度

    js實現(xiàn)兼容IE6與IE7的DIV高度

    兼容IE6與IE7的DIV高度的js代碼,
    2010-05-05
  • javascript實現(xiàn)獲取瀏覽器版本、操作系統(tǒng)類型

    javascript實現(xiàn)獲取瀏覽器版本、操作系統(tǒng)類型

    這篇文章主要給大家分享一段javascript實現(xiàn)獲取瀏覽器版本、操作系統(tǒng)類型的封裝好的代碼,使用非常方便,也很實用,推薦給大家。
    2015-01-01
  • JavaScript判斷元素是否在可視區(qū)域的三種方法

    JavaScript判斷元素是否在可視區(qū)域的三種方法

    這這篇文章給大家總結(jié)了JavaScript判斷元素是否在可視區(qū)域的三種方法,getBoundingClientRect,IntersectionObserver和offsetTop、scrollTop這三種方法,文中通過代碼示例給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-12-12
  • JavaScript閉包原理及作用詳解

    JavaScript閉包原理及作用詳解

    閉包是指內(nèi)部函數(shù)總是可以訪問其所在的外部函數(shù)中聲明的變量和參數(shù),即使在其外部函數(shù)被返回(壽命終結(jié))了之后。這篇文章將為大家詳細(xì)介紹一下閉包的原理,作用及用途,快來跟隨小編一起學(xué)習(xí)一下吧
    2021-12-12
  • JavaScript Sort 表格排序

    JavaScript Sort 表格排序

    JavaScript表格排序?qū)崿F(xiàn)代碼,需要的朋友可以參考下。
    2009-10-10
  • js監(jiān)聽html頁面的上下滾動事件方法

    js監(jiān)聽html頁面的上下滾動事件方法

    今天小編就為大家分享一篇js監(jiān)聽html頁面的上下滾動事件方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-09-09

最新評論

射阳县| 张家港市| 称多县| 香格里拉县| 长寿区| 濮阳县| 金秀| 临安市| 洛南县| 宜州市| 新和县| 岳池县| 布拖县| 盐池县| 仙居县| 张家口市| 乌拉特前旗| 永春县| 尚义县| 即墨市| 兰考县| 天柱县| 罗平县| 南澳县| 嫩江县| 乐都县| 五河县| 中阳县| 昭通市| 宁阳县| 江华| 青铜峡市| 清镇市| 屏东县| 翁源县| 崇左市| 锡林浩特市| 磐安县| 邹平县| 安平县| 修武县|