Skip to content
New issue

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

vue 解决addRoutes动态添加路由后刷新失效问题(跳转“404”页面) #12

Open
zuobaiquan opened this issue Nov 18, 2020 · 0 comments

Comments

@zuobaiquan
Copy link
Owner

解决方法是 不要在路由中添加404页面 在addRoutes里进行拼接 (通配符 * 跳转到404页面的路由)
在beforeEach中打印 to发现是404 打印from显示是/

这样子更可以确定 当页面一刷新 addRoutes 还没有添加上 路由就开始跳转了 所以找不到路由就跳转到404页面了。

在网上找了许久发现是 不能在自己写的路由里边添加404 要在addRoutes中添加404页面不然就会跳转404 所以我把代码改成下面这个样子 最后添加路由的 通配符 * 跳转404 页面果然好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant