Component({ data: { selected: 0, color: "#7A7E83", selectedColor: "#1070E8", list: [] }, attached () { let userRole = wx.getStorageSync('userRole'); // 0 表示普通用户 1表示管理员 console.log('userRole', userRole); if (userRole && userRole.includes('管理')) { this.setData({ list: getApp().globalData.managerList }) } else { this.setData({ list: getApp().globalData.inspecterList }) } }, methods: { switchTab (e) { const data = e.currentTarget.dataset const url = data.path // this.setData({ // selected: data.index // }) wx.switchTab({ url }) } } })