微信小程序實現(xiàn)選項卡效果
更新時間:2018年11月06日 11:35:09 作者:nobug12138
這篇文章主要介紹了微信小程序實現(xiàn)選項卡效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序實現(xiàn)選項卡效果展示的具體代碼,供大家參考,具體內容如下
demo.wxss
.swiper-tab{
width: 100%;
border-bottom: 2rpx solid #777777;
text-align: center;
line-height: 80rpx;}
.swiper-tab-list{ font-size: 30rpx;
display: inline-block;
width: 33.33%;
color: #777777;
}
.on{ color: #da7c0c;
border-bottom: 5rpx solid #da7c0c;}
.swiper-box{ display: block; height: 100%; width: 100%; overflow: hidden; }
.swiper-box view{
text-align: center;
}
demo.wxml
<view class="swiper-tab">
<view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">哈哈</view>
<view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">呵呵</view>
<view class="swiper-tab-list {{currentTab==2 ? 'on' : ''}}" data-current="2" bindtap="swichNav">嘿嘿</view>
</view>
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight - 31}}px" bindchange="bindChange">
<!-- 我是哈哈 -->
<swiper-item>
<view>我是哈哈</view>
</swiper-item>
<!-- 我是呵呵 -->
<swiper-item>
<view>我是呵呵</view>
</swiper-item>
<!-- 我是嘿嘿 -->
<swiper-item>
<view>我是嘿嘿</view>
</swiper-item>
</swiper>
demo.js
Page( {
data: {
/**
* 頁面配置
*/
winWidth: 0,
winHeight: 0,
// tab切換
currentTab: 0,
},
onLoad: function() {
var that = this;
/**
* 獲取系統(tǒng)信息
*/
wx.getSystemInfo( {
success: function( res ) {
that.setData( {
winWidth: res.windowWidth,
winHeight: res.windowHeight
});
}
});
},
/**
* 滑動切換tab
*/
bindChange: function( e ) {
var that = this;
that.setData( { currentTab: e.detail.current });
},
/**
* 點擊tab切換
*/
swichNav: function( e ) {
var that = this;
if( this.data.currentTab === e.target.dataset.current ) {
return false;
} else {
that.setData( {
currentTab: e.target.dataset.current
})
}
}
})
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 微信小程序自定義組件實現(xiàn)tabs選項卡功能
- 微信小程序實現(xiàn)導航欄選項卡效果
- 微信小程序實現(xiàn)選項卡功能
- 微信小程序之選項卡的實現(xiàn)方法
- 微信小程序實現(xiàn)頂部普通選項卡效果(非swiper)
- 微信小程序實現(xiàn)頂部選項卡(swiper)
- 微信小程序 選項卡的簡單實例
- 微信小程序實戰(zhàn)之頂部導航欄(選項卡)(1)
- 微信小程序開發(fā)之選項卡(窗口底部TabBar)頁面切換
- 微信小程序 tabs選項卡效果的實現(xiàn)
- 微信小程序開發(fā)之實現(xiàn)選項卡(窗口頂部TabBar)頁面切換
- 微信小程序 實現(xiàn)tabs選項卡效果實例代碼
- 小程序實現(xiàn)頁面頂部選項卡效果
相關文章
ES6數(shù)組復制和填充方法copyWithin()、fill()的具體使用
本文主要介紹了ES6數(shù)組復制和填充方法copyWithin()、fill()的具體使用,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10
webpack4升級到webpack5的實戰(zhàn)經(jīng)驗總結
有些老項目的包長時間沒有更新,導致項目中有些性能問題,在項目迭代中考慮升級包,下面這篇文章主要給大家介紹了關于webpack4升級到webpack5的實戰(zhàn)經(jīng)驗,需要的朋友可以參考下2022-08-08

