We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在主应用中 配置了路由{ path:'*', name:'404', component: () =>import('../views/404.vue') } 我现在访问子应用的路由 在路由守卫中的next()后会直接跳转到404页面
The text was updated successfully, but these errors were encountered:
这是正常表现,你不应该写通配符 * ,你可以将 404 页面注册为一个普通路由页面,比如说 /404 ,然后在主项目的路由钩子函数router.beforeEach 里面判断一下,如果既不是主项目路由,也不是子项目,就跳转到 404 页面,伪代码如下:
*
/404
router.beforeEach
const childrenPath = ['/app1','/app2']; router.beforeEach((to, from, next) => { if(to.name) { // 有name属性,说明是主项目的路由 next() } if(childrenPath.some(item => to.path.includes(item))){ next() } next({ name:'404' }) })
Sorry, something went wrong.
thank you
const childrenPath = ['/app1','/app2']; router.beforeEach((to, from, next) => { if(to.name) { // 有name属性,说明是主项目的路由 return next() } if(childrenPath.some(item => to.path.includes(item))){ return next() } next({ name:'404' }) })
这段代码应该要加 return ,不然 next() 之后的代码还是会执行到的
No branches or pull requests
提问之前强烈建立您能先阅读一下《提问的智慧》
What happens?
在主应用中 配置了路由{
path:'*',
name:'404',
component: () =>import('../views/404.vue')
}
我现在访问子应用的路由 在路由守卫中的next()后会直接跳转到404页面
在主应用中 配置了路由{
path:'*',
name:'404',
component: () =>import('../views/404.vue')
}
我现在访问子应用的路由 在路由守卫中的next()后会直接跳转到404页面
相关环境信息
The text was updated successfully, but these errors were encountered: