在项目中遇到这么一个需求,登录页面跳转不存在的路由都重新指向登录页面,但是loginNocode页面除外,要跳转loginNocode,
登陆之后跳转不存在的路由的时候跳转404页面
我是在main.js中的router.beforeEach写的。中心代码如下:
if (!tokenStr){ if (to.path!='/loginNocode') return next('/') }else{ // console.log(to.path.slice(1),'====',to.matched,'111111111',from) if(to.matched.length == 0) return next('/error') if(to.path.slice(1) == 'error'){ store.state.fourErrorNavShow = false }else{ store.state.fourErrorNavShow = true } };