Files
kairos_miniapp/custom-tab-bar/index.js
2026-03-27 17:55:18 +08:00

43 lines
704 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/chat/index",
label: 'AI助手',
icon: 'chat-bubble'
},
{
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 })
}
}
}
})