Files
kairos_miniapp/custom-tab-bar/index.js
2026-03-27 13:29:41 +08:00

38 lines
615 B
JavaScript

// custom-tab-bar/index.js
Component({
lifetimes: {
attached: function () {
this.getTabBar(tabBar => {
let value = tabBar.data.selected
this.setData({
selected: value
})
})
},
},
data: {
selected: '',
tabList: [
{
path: "/pages/home/index",
label: '首页',
icon: 'home'
},
{
path: "/pages/expert/index",
label: '专家服务',
icon: 'call-1'
}
]
},
methods: {
switchTab(e) {
let value = e.detail.value
let info = this.data.tabList.find(item => item.label == value)
if (info) {
wx.switchTab({ url: info.path })
}
}
}
})