// custom-tab-bar/index.js Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { active: 0, list: [ { value: 0, label: '发薪', icon: 'money-circle' }, { value: 1, label: '我的', icon: 'user' }, ], pageList: [{ url: '/pages/merchant/payroll' }, { url: '/pages/merchant/my' }] }, /** * 组件的方法列表 */ methods: { changePage(e) { getApp().globalData.active = e.detail.value; wx.switchTab({ url: this.data.pageList[e.detail.value].url, }) }, init() { const page = getCurrentPages().pop(); this.setData({ active: this.data.pageList.findIndex(item => item.url === '/' + `${page?.route}`) }) } } })