wx.switchTab({ 'url': '/pages/agent_equipment/agent_equipment' })
自定义tabbar,不同角色进来显示不一样的tabbar,上一个角色登录,缓存还在。怎么解决?const app = getApp(); Component({ data: { selected: "custom": true "color": "#472E0B" "selectedColor": "#472E0B" "borderStyle": "black" "backgroundColor": "#ccc" // 菜单1 "list": [ ], "list1": [ { "pagePath": "/pages/orderList/orderList" "text": "订单" "iconPath": "../images/dingdanhui.png" "selectedIconPath": "../images/dingdanlan.png" }, { "pagePath": "/pages/mine/mine" "text": "我的" "iconPath": "../images/minhui.png" "selectedIconPath": "../images/minelan.png" } ], //菜单2 "list2": [ { "pagePath": "/pages/agent_equipment/agent_equipment" "text": "设备" "iconPath": "../images/shebei1.png" "selectedIconPath": "../images/shebei.png" }, { "pagePath": "/pages/agent_me/agent_me" "text": "我的" "iconPath": "../images/me.png" "selectedIconPath": "../images/me1.png" } ], "position": "bottom" }, // -- 初始化判断角色 attached() { this.setData({ list: [] }) if ( 100 == app.globalData.type){ this.setData({ list: this.data.list2 }) }else this.setData({ list: this.data.list1 }) } }, methods: { switchTab(e) { const data = e.currentTarget.dataset; const url = data.path; wx.switchTab({ url: url }) this.setData({ selected: data.index }) } } }) <!-- wxm l--> cover-viewclass"tab-bar"> cover-viewclass"tab-bar-border"></cover-view cover-viewwx:for"{{list}}"wx:key"index"class"tab-bar-item"data-path"{{item.pagePath}}"data-index"{{index}}"bindtap"switchTab"> cover-imagesrc"{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image cover-viewstyle"color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view </cover-view </cover-view
2019-12-27