初始化
This commit is contained in:
38
custom-tab-bar/index.js
Normal file
38
custom-tab-bar/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// 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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user