问题: this.$router.push(’/upload’);点击跳转成功 但控制台报出如下错误
vue-router.esm.js?fe87:2051 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated
解决方法:
import VueRouter from 'vue-router'
// 过滤如下报错:
// 错误信息如下: Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"};
// 解决方法一:经过多次尝试发现原因可能是 在重新下载依赖包时,安装的vue-router还是之前出错的那个版本,解决方法也很简单,在项目目录下运行 npm i vue-router@3.0 -S 即可。
// 解决方法二:如果你不想用方法一那就在 main.js里添加一段代码。
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return routerPush.call(this, location).catch(error=> error)
}
Vue.use(VueRouter)