微信小程序?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)文章
uni-app?微信小程序授權(quán)登錄的實現(xiàn)步驟
本文主要介紹了uni-app?微信小程序授權(quán)登錄的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-01-01前臺js改變Session的值(用ajax實現(xiàn))
前臺js改變Session的值,有很多的新手朋友對此問題會很陌生,本文將提供解決方法,需要了解的朋友可以參考下2012-12-12解決layui的使用以及針對select、radio等表單組件不顯示的問題
今天小編就為大家分享一篇解決layui的使用以及針對select、radio等表單組件不顯示的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09關(guān)于Javascript 對象(object)的prototype
Javascript中的每個對象(object)都會有 prototype,下面為大家介紹下其具體的應(yīng)用2014-05-05對setInterval在火狐和chrome切換標簽產(chǎn)生奇怪的效果之探索,與解決方案!
其實這個問題,已經(jīng)困擾我很近。就是切換瀏覽器標簽之后,再等幾十秒的時間切換回來setInterval就亂了陣,過一會又正常了!IE瀏覽器就沒有這種奇怪的現(xiàn)象!2011-10-10document.open() 與 document.write()的區(qū)別
document.open() 與 document.write()的區(qū)別...2007-08-08