要在首页判断是否登录,未登录跳转到登录页,不知道咋回事登录页底部也出现了tabbar
看了一下,是uni-simple-router的bug
插件介绍这样说:
APP
端启动页为tab时,拦截到其他页面后底部tabbar 还依然存在,请避免把原生tabbar
页设置成启动页。你可以在beforeEach
中使用 next 到tabbar页效果一致
但是首页是启动页比较合理,
{
"path": "pages/index/index",
"meta": {
"noAuth": true
},
"style": {
"navigationBarTitleText": "首页",
"navigationStyle": "custom"
}
},
这时候需要在page.json中给首页添加meta配置项
在router.beforeEach中判断,将首页放开
if (to.meta && to.meta.noAuth) {
next()
}
然后在响应拦截器中判断请求的status,不是200就跳到登录页,通过请求的返回状态判断是否登录