2022-03-08 22:40阅读: 199评论: 0推荐: 0

解决Vue重复路由产生的错误

Vue项目中路由重复

产生如下报错

Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/main/index".
原因:vue-router路由版本更新产生的问题,导致路由跳转失败抛出该错误,但并不影响程序功能

image

解决方法

在 router下的 index.js 中插入如下代码

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

问题解决

本文作者:朝颜浅语

本文链接:https://www.cnblogs.com/ommggg/p/15982908.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   朝颜浅语  阅读(199)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起