微信小程序-tab切换

//wxml

<view class="wrap">
<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>
 
<swiper current="{{currentTab}}" class="swiper-box" duration="300" style="height:{{winHeight-36}}px" bindchange="bindChange">
<!-- 简介 -->
<swiper-item>
<scroll-view class="intro_main" style="height:{{winHeight-36}}px" scroll-y="true">
<view class="vipList">
<view class="vipListBar" wx:for="{{11}}">
<view class="vipListBarBox">
<view class="vipListBarBoxLeft">VIP服务码</view>
<view class="vipListBarBoxRight">VMI9E3L3G9</view>
</view>
<view class="vipListBarText">复制使用</view>
</view>
</view>
</scroll-view>
</swiper-item>
<!-- 目录 -->
<swiper-item>
<scroll-view class="Catalog" style="height:{{winHeight-36}}px" scroll-y="true">
<view class="vipList">
<view class="vipListBar" wx:for="{{9}}">
<view class="vipListBarBox">
<view class="vipListBarBoxLeft leftActive">VIP服务码</view>
<view class="vipListBarBoxRight RightActive">VMI9E3L3G9</view>
</view>
<view class="vipListBarText active">已失效</view>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
 
.swiper-tab{
width: 100%;
border-bottom: 1rpx solid #e6e6e6;
text-align: center;
line-height: 68rpx;
box-sizing: border-box;
display: flex;
justify-content: space-around;
}
.swiper-tab-list{
font-size: 30rpx;
width:100rpx;
color: #999999;
font-weight: bold;
 
}
.on{
color: #333333;
border-bottom: 4rpx solid #da7c0c;
}
.swiper-box{ display: block; width: 100%; overflow: hidden; margin-bottom: 100rpx;}
 
data: {
winWidth: 0,
winHeight: 0,
// tab切换
currentTab: 0,
},
// 滑动切换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
})
}
},
onLoad: function (options) {
var that= this;
wx.getSystemInfo({
success: function (res) {
that.setData({
winWidth: res.windowWidth,
winHeight: res.windowHeight
});
}
})
},

转载于:https://www.cnblogs.com/weiwentaweb/p/8257411.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值