|
效果圖,既可以點擊切換,又可以滑動切換
.wxml
.wxss
/* pages/detail/detail.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;
}
.js
// pages/detail/detail.js
var app = getApp()
Page({
data: {
currentTab: 0
},
onLoad: function (options) {
// 頁面初始化 options為頁面跳轉所帶來的參數(shù)
},
//滑動切換
swiperTab: function (e) {
var that = this;
that.setData({
currentTab: e.detail.current
});
},
//點擊切換
clickTab: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
}
})
|