1.vxml
<view class='productNav'>
<view class='left'>
<view class="{{active==0?'selected':'normal'}}" id="0" bindtap='switchNav'>为您推荐</view>
<view class="{{active==1?'selected':'normal'}}" id="1" bindtap='switchNav'>电脑</view>
<view class="{{active==2?'selected':'normal'}}" id="2" bindtap='switchNav'>手机</view>
</view>
<view class='right'>
<view class='type'>
<swiper current='{{currentTab}}' vertical='{{true}}'>
<swiper-item id="0" catchtouchmove="false">
为您推荐
</swiper-item>
<swiper-item id="1" catchtouchmove="false">
手机
</swiper-item>
<swiper-item id="2" catchtouchmove="false">
电脑
</swiper-item>
</swiper>
</view>
</view>
</view>
2.js
Page({
data: {
active:0,
currentTab:0
},
switchNav: function (e) {
var page = this;
var id = e.target.id;
if (this.data.currentTab == id) {
return false;
} else {
page.setData({
currentTab: id
});
}
page.setData({
active: id
});
}
})
3.css
.productNav{
display: flex;
flex-direction: row;
font-family: "Microsoft YaHei"
}
.left{
width: 25%;
font-size: 30rpx;
background-color: #f4f4f4;
}
.left view{
text-align: center;
height: 90rpx;
line-height: 90rpx;
}
.selected{
background-color: #fff;
border-left: 2px solid #E54847;
font-weight: bold;
color: #E54847;
}
.normal{
background-color: #f4f4f4;
border-bottom: 1px solid #f2f2f2;
}
.right{
width:75%;
margin: 0;
}
swiper{
height: 500px;
}