js代码
uni.setTabBarItem({
index: 0,
"pagePath": "pages/reader/home",
"text": "读者",
"iconPath": "static/images/tabbar/book.png",
"selectedIconPath": "static/images/tabbar/book-fill.png"
});
uni.switchTab({
url: '/pages/reader/home'
})
pages.json
"tabBar": {
"color": "#333333",
"backgroundColor": "#F8F8F8",
"selectedColor": "#2979ff",
"list": [{
"pagePath": "pages/store/home",
"text": "首页",
"iconPath": "static/images/tabbar/home.png",
"selectedIconPath": "static/images/tabbar/home-fill.png"
},
{
"pagePath": "pages/activity/activityList",
"text": "活动",
"iconPath": "static/images/tabbar/activity.png",
"selectedIconPath": "static/images/tabbar/activity-fill.png"
},
{
"pagePath": "pages/book/bookList",
"text": "书籍",
"iconPath": "static/images/tabbar/book.png",
"selectedIconPath": "static/images/tabbar/book-fill.png"
},
{
"pagePath": "pages/test/videoCompress",
"text": "拼书",
"iconPath": "static/images/tabbar/group-book.png",
"selectedIconPath": "static/images/tabbar/group-book-fill.png"
},
{
"pagePath": "pages/test/menu",
"text": "我的",
"iconPath": "static/images/tabbar/mine.png",
"selectedIconPath": "static/images/tabbar/mine-fill.png"
}
]
}
c***@qq.com (作者)
感谢回复。我大概知道问题出在哪了。我给的demo其实还不够全面。
比如,我当前在登录页,从后端提交请求后,获取到角色,需要刷新即将跳转过去的tabbar的pagePath。在跳过去之前,先在登录页写了uni.setTabBarItem。这样写就跳不过去了。
可能是还未跳转到tabbar所在的页面之前,就更新了它的配置,就无法生效。
2020-12-10 15:55