const app = getApp() Component({ data: { selected: 0, list: [ { pagePath: '/pages/index/index', text: '首页', icon: '🏠' }, { pagePath: '/pages/chapters/chapters', text: '目录', icon: '📋' }, { pagePath: '/pages/match/match', text: '找伙伴', icon: '👥', hidden: true, isCenter: true }, { pagePath: '/pages/my/my', text: '我的', icon: '👤' } ] }, methods: { syncMatchEnabled() { const matchEnabled = app.globalData.matchEnabled === true const list = this.data.list.map((item) => { if (item.text === '找伙伴') { return { ...item, hidden: !matchEnabled } } return item }) this.setData({ list }) }, switchTab(e) { const path = e.currentTarget.dataset.path const index = e.currentTarget.dataset.index this.setData({ selected: index }) wx.switchTab({ url: path }) } }, attached() { this.syncMatchEnabled() app.loadFeatureConfig().then(() => this.syncMatchEnabled()) }, pageLifetimes: { show() { app.loadFeatureConfig().then(() => this.syncMatchEnabled()) } } })