-
-
Notifications
You must be signed in to change notification settings - Fork 5k
console warnin:Duplicate named routes definition #1727
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
Comments
Hello, your issue has been closed because it does not conform to our issue requirements. Please use the Issue Helper to create an issue - thank you! |
遇到同样的问题 |
遇到同样的问题,请问解决了么 |
是不是 oldNameMap 缓存在内存中,当你再次登录的时候,如果没有刷新页面,会去比对你之前添加的oldNameMap, 但是你登录的时候要是刷新页面就不会有问题,有可能是这个问题。 |
name 同名了导致 |
@shapl |
遇到同样的问题,请问解决了么 |
same problem. |
遇到同样的问题,请问解决了么 |
同问 |
same problem |
? |
解决方案:
2.在需要使用addRoutes的地方,导入该函数
|
@luichooy
|
楼上正解,亲测有效 |
router.matcher = createRouter().matcher; 这个方法并不生效,有知道怎么回事吗 |
各位大佬们 match 并不生效 如何解决啊 |
我的微信1005922744 |
亲测有效,谢谢楼主 |
最后你解决了吗,可以发出来看看吗 |
我在退出的时候 通过window.loacation.href的方式解决了,那个方法我这边不行 |
你可能需要在你的环境中使用this.$router来代替router |
same problem 使用了上述方式,都不生效 |
import Vue from 'vue' Vue.use(Router) const createRouter = () => new Router({ const router = createRouter() export function resetRouter () { export default router |
我现在有一个这样的场景:
1,默认路由数组只有两个 ,根和登录。
2,登录之后,我会进行动态添加路由,实现方法如下:
this.$router.options.routes = new_routes;
this.$router.addRoutes(this.$router.options.routes);
3,然后退出的时候,再把动态添加的路由干掉,实现方式和上面类似:
this.$router.options.routes = new_routes;//new_routes确定只有两个
this.$router.addRoutes(this.$router.options.routes);
console.log(this.$router.options.routes);//这里也确定只有两个
此时此刻一切都正常,没有任何问题,然而
当我在登录时,重复第二步的操作的时候,会出现以下一大堆警告:
[vue-router] Duplicate named routes definition: { name: "日期时间", path: "/components/form/datetime" }
......
......
凡是在第一次动态添加过的路由,二次动态添加的时候,全部都会出现这些,但功能逻辑操作上,一切都没有问题。
不知道什么原因?或者有没有办法不让显示这个警告,尝试使用
Vue.config.productionTip = false;
Vue.config.devtools = false;
上面这两种方式关闭警告,但对vue-router不好使,查看源码之后,发现开发模式必须会警告,求解决办法。
如果方便,请回复中文,谢谢。
The text was updated successfully, but these errors were encountered: