data: {
tabs: [
{ title: '全部', id: 1 },
{ title: '待支', id: 2 },
{ title: '待入住', id: 3 },
{ title:'已取消', id: 4 }
],
activeTab: 1,
}
changeTabs(e) {
let { tab } = e.currentTarget.dataset
this.setData({
activeTab: tab
})
},
<view class="tabs">
<view class="tabs_title">
<view wx:for="{{tabs}}" wx:key="index" data-tab="{{item.id}}"
class="tabs_item {{activeTab === item.id? 'tabActiveColor' : ''}} "
bindtap="changeTabs">{{item.title}}
</view>
</view>
<view class="tabs_content">
<view hidden='{{activeTab != 1}}'>页面1</view>
<view hidden='{{activeTab != 2}}'>页面2</view>
<view hidden='{{activeTab != 3}}'>页面3</view>
<view hidden='{{activeTab != 4}}'>页面4</view>
</view>
</view>