原理:
根据current渲染class样式;
wxml:
<view class='tabbar'>
<view class="{{current==1?'tab-item item-on':'tab-item'}}" bindtap='select' data-index='1'>tab1</view>
<view class="{{current==2?'tab-item item-on':'tab-item'}}" bindtap='select' data-index='2'>tab2</view>
</view>
js:
const app = getApp()
const url=app.data.url
Page({
data: {
current:1,
},
//事件处理函数
select:function(e){
this.setData({
current: e.currentTarget.dataset.index
})
},
onLoad: function () {
}
})