微信小程序实现,可滑动、可点击
tab.wxml:
全部
中奖
未中奖
全部
中奖
未中奖
tab.wxss:
.swiper-tab {
width: 100%;
border-bottom: 2rpx solid #ccc;
text-align: center;
height: 88rpx;
line-height: 88rpx;
display: flex;
flex-flow: row;
justify-content: space-between;
}
.swiper-tab-item {
width: 30%;
color: #434343;
}
.active {
color: #f65959;
border-bottom: 4rpx solid #f65959;
}
swiper {
text-align: center;
background-color: #fff
}
tab.js:
Page({
data: {
currentTab: 0
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
},
//滑动切换
swiperTab: function (e) {
this.setData({
currentTab: e.detail.current
});
},
//点击切换
clickTab: function (e) {
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
this.setData({
currentTab: e.target.dataset.current
})
}
}
})