购物车小程序列表状态

<scroll-view class="nav_left" scroll-y>
<block wx:key="{{index}}" wx:for="{{navLeftItems}}">
//当前点击的项等于当前点击下标添加 class
<view class="nav_left_items {{curIndex == index ? ‘nav_left_item-active‘ : ‘‘}}" data-index="{{index}}" bindtap="switchRightTab">
{{item}}
</view>

 

购物车小程序列表状态
</block>
</scroll-view>
//默认等于0
data:{
curIndex: 0,
}
 
switchRightTab(e) {
let index = parseInt(e.currentTarget.dataset.index);
this.setData({
curIndex: index
})
},

相关文章