前端踩坑(四)(vue)报错 Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"

解决办法有三个
1.升级你的vue router 版本
2.降低你的vue.js 版本
3.在main.js 中加入以下代码

// 解决Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"的报错
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

后来经过查阅其他人的解决方法(https://blog.csdn.net/wwf1225/article/details/102805712)
得知仅有[email protected]版本会出现此错误,因为此版本使用了promise进行跳转而没有进行catch。

这篇文章中没有提到的是,高版本的vue.js对于vue-router

你可能感兴趣的:(踩坑排错,vue)