VueRouter路由跳转报错:vue-router.esm.js?fe87:2100 Uncaught (in promise) NavigationDuplicated
错误信息:
vue-router.esm.js?fe87:2100 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/home") is not allowed", stack: "Error↵ at new NavigationDuplicated (webpack-int…node_modules/vue/dist/vue.runtime.esm.js:2178:14)"}
出现情况:
解决方案:
1、在使用 replace、push等方法时捕获异常
2、在包含这句代码 Vue.use(Router) 的文件中加入如下代码:
即可解决问题