Vue使用路由报错

报错:

  Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/user/zhangsan".

  

 

解决办法:

  看自己是选用了什么样的跳转方式:两种跳转方式push和replace

  push:

Vue.use(Router)

const originalPush1 = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush1.call(this, location).catch(err => err)
}

  replace:

Vue.use(Router)
const originalReplace2 = Router.prototype.replace;
Router.prototype.replace = function replace(location) {
return originalReplace2.call(this, location).catch(err => err);
};


posted @ 2020-12-25 19:56  假装空白  阅读(224)  评论(0编辑  收藏  举报