wxml
<view>
<view class="tabNav">
<view wx:for="{{navTab}}" wx:key="index" data-name="{{item.type}}" data-key="{{index}}" bindtap="currentTab" class="{{currentTab==index ? 'cur' : ''}}"><text class="text-col">{{item.name}}</text> </view>
</view>
</view>
wxss
.text-col {
color:#80bd01
}
.cur text{
height:40rpx;
background-color:#80bd01;
color:#fff;
padding:3rpx 4rpx;
box-sizing: border-box;
border-radius: 6rpx;
}
js
Page({
data: {
currentTab: 0,
},
currentTab: function (e) {
this.setData({
currentTab: e.currentTarget.dataset.key
})
}
})
