微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動(dòng)條不顯示的方法示例
本文實(shí)例講述了微信小程序?qū)崿F(xiàn)swiper切換卡內(nèi)嵌滾動(dòng)條不顯示的方法。分享給大家供大家參考,具體如下:
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)用實(shí)例 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ò)請(qǐng)求,可能會(huì)在 Page.onLoad 之后才返回 // 所以此處加入 callback 以防止這種情況 app.userInfoReadyCallback = res => { this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } } else { // 在沒(méi)有 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 }) } } })
希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。
- 微信小程序?qū)崿F(xiàn)橫向滾動(dòng)條
- 微信小程序?qū)崿F(xiàn)滾動(dòng)條功能
- 微信小程序scroll-view隱藏滾動(dòng)條的方法詳解
- 微信小程序scroll-view的滾動(dòng)條設(shè)置實(shí)現(xiàn)
- 微信小程序設(shè)置滾動(dòng)條過(guò)程詳解
- 詳解微信小程序scroll-view橫向滾動(dòng)的實(shí)踐踩坑及隱藏其滾動(dòng)條的實(shí)現(xiàn)
- 微信小程序scroll-view仿拼多多橫向滑動(dòng)滾動(dòng)條
- 微信小程序-橫向滑動(dòng)scroll-view隱藏滾動(dòng)條
- 微信小程序 scroll-view隱藏滾動(dòng)條詳解
- 微信小程序scroll-view實(shí)現(xiàn)自定義滾動(dòng)條
相關(guān)文章
JS密碼生成與強(qiáng)度檢測(cè)完整實(shí)例(附demo源碼下載)
這篇文章主要介紹了JS密碼生成與強(qiáng)度檢測(cè)完整實(shí)例,涉及JavaScript密碼的生成,破解時(shí)間計(jì)算,密碼安全監(jiān)測(cè)及大小寫鎖定判斷等功能的實(shí)現(xiàn)技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-04-04uni-app?微信小程序授權(quán)登錄的實(shí)現(xiàn)步驟
本文主要介紹了uni-app?微信小程序授權(quán)登錄的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-01-01前臺(tái)js改變Session的值(用ajax實(shí)現(xiàn))
前臺(tái)js改變Session的值,有很多的新手朋友對(duì)此問(wèn)題會(huì)很陌生,本文將提供解決方法,需要了解的朋友可以參考下2012-12-12Javascript 浮點(diǎn)運(yùn)算精度問(wèn)題分析與解決
浮點(diǎn)數(shù)的精度問(wèn)題不是JavaScript特有的,因?yàn)橛行┬?shù)以二進(jìn)制表示位數(shù)是無(wú)窮的2014-03-03解決layui的使用以及針對(duì)select、radio等表單組件不顯示的問(wèn)題
今天小編就為大家分享一篇解決layui的使用以及針對(duì)select、radio等表單組件不顯示的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09關(guān)于Javascript 對(duì)象(object)的prototype
Javascript中的每個(gè)對(duì)象(object)都會(huì)有 prototype,下面為大家介紹下其具體的應(yīng)用2014-05-05對(duì)setInterval在火狐和chrome切換標(biāo)簽產(chǎn)生奇怪的效果之探索,與解決方案!
其實(shí)這個(gè)問(wèn)題,已經(jīng)困擾我很近。就是切換瀏覽器標(biāo)簽之后,再等幾十秒的時(shí)間切換回來(lái)setInterval就亂了陣,過(guò)一會(huì)又正常了!IE瀏覽器就沒(méi)有這種奇怪的現(xiàn)象!2011-10-10document.open() 與 document.write()的區(qū)別
document.open() 與 document.write()的區(qū)別...2007-08-08