js部分
Page({
data: {
curTab: 0,
current: 0,
tabList: [{
id: 1,
name: "分类"
},
{
id: 2,
name: "推荐"
},
{
id: 3,
name: "精品"
}, {
id: 4,
name: "直播"
},
{
id: 5,
name: "广播"
},
{
id: 6,
name: "其他"
}
]
},
selectTab(e) {
let index = e.target.dataset.index;
this.setData({
curTab: index,
current: index
})
},
swiperChange(e) {
let index = e.detail.current;
this.setData({
curTab: index,
current: index
})
}
})
wxml
<scroll-view class="tab-list" scroll-x scroll-with-animation>
<view wx:for="{
{tabList}}" class="tab-item {
{curTab===index ? 's