<view catchtouchmove='true'>
<view class='navBox'>
<view class='titleBox1' id="allaid" bindtap='titleClick' data-idx='0'>
<text class="{{0 == currentIndex ? 'fontColorBox' : 'fontColorBox1'}}">tab1</text>
<view class="line" wx:if="{{currentIndex ==0}}"></view>
</view>
<view class='titleBox2' bindtap='titleClick' data-idx='1'>
<text class="{{1 == currentIndex ? 'fontColorBox' : 'fontColorBox1'}}">tab2</text>
<view class="line" wx:if="{{currentIndex ==0}}"></view>
</view>
</view>
<!-- 内容布局 -->
<swiper class='swiperTtemBox' bindchange='pagechange' current='{{currentIndex}}'>
<swiper-item catchtouchmove='onTouchMove'>
</swiper-item>
<swiper-item catchtouchmove='onTouchMove'>
<view>
tab2
</view>
</swiper-item>
</swiper>
</view>
data: {
currentIndex: 0,
},
//点击tab时触发
titleClick: function (e) {
this.setData({
//拿到当前索引并动态改变
currentIndex: e.currentTarget.dataset.idx
})
},