购物车小程序列表状态
时间:2020-07-26 01:29:05
收藏:0
阅读:106
<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
})
},
评论(0)