// custom-tab-bar/index.ts const app = getApp() Component({ /** * 组件的属性列表 */ properties: { }, ready() { this.setData({ pageName: app.globalData.tabActive }) }, /** * 组件的初始数据 */ data: { pageName: "" }, /** * 组件的方法列表 */ methods: { changepage(e: any) { const url = e.target.dataset.index; if(app.globalData.tabActive === url) return app.globalData.tabActive = url; wx.switchTab({ url }) } } })