// custom-tab-bar/index.ts Component({ /** * 组件的属性列表 */ properties: { }, options: { styleIsolation: 'shared' }, /** * 组件的初始数据 */ data: { active: 0, color: '#888888', activeColor: '#387BDC', list: [ { icon: 'wap-home', text: '首页', url: '/pages/home/index' }, { icon: 'balance-list', text: '挂牌大厅', url: '/pages/trade/index' }, { icon: 'gem', text: '钻石圈', url: '/pages/circle/index' }, { icon: 'manager', text: '我的', url: '/pages/mine/index' } ] }, /** * 组件的方法列表 */ methods: { onChange(e: any) { wx.switchTab({ url: this.data.list[e.detail].url }); this.setData({ active: e.detail }); }, init() { const page = getCurrentPages().pop(); this.setData({ active: this.data.list.findIndex(item => item.url === `/${page.route}`) }); } } })