美文网首页vue前端知识
vue3.0vue-router报错解决方案

vue3.0vue-router报错解决方案

作者: 一只正在成长的程序猿 | 来源:发表于2020-01-06 10:27 被阅读0次

VUE.js项目中控制台报错: Uncaught (in promise) NavigationDuplicated解决方法

问题愿意:依赖包中vue-router出现问题(猜测为版本问题);

解决方法:在项目目录下运行

 npm i vue-router@3.0 -S

这条指令就可以解决了。(更换版本)

或者在main.js中添加以下代码:

import Router from 'vue-router'

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

相关文章

网友评论

    本文标题:vue3.0vue-router报错解决方案

    本文链接:https://www.haomeiwen.com/subject/efihactx.html