Vue router报错:NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}的解决方法

我最近做SPA项目开发动态树的时候一直遇到以下错误:

Vue router报错:NavigationDuplicated {_name:
当我点击文章管理需要跳转路径时一直报NavigationDuplicated {_name: “NavigationDuplicated”, name: “NavigationDuplicated”}这个错误

Vue router报错:NavigationDuplicated {_name:
但是当我点击文章管理后,路径跳转却是成功的

话不多说,放图:
Vue router报错:NavigationDuplicated {_name:

解决方法:

在main.js下添加:

import Router from 'vue-router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue router报错:NavigationDuplicated {_name:

Vue router报错:NavigationDuplicated {_name:

这样就OK啦,希望这篇博客能帮助到大家!!

你可能感兴趣的:(前端)