head-img Force's Blog

NavigationDuplicated: Avoided redundant navigation to current location: “/“

JavaScript

关于VUE项目中报NavigationDuplicated: Avoided redundant navigation to current location: "/" 的错

原因:是指路由重复。

      虽然对项目无影响,但是看到有红的不舒服!

解决方法:

打开router文件夹下的index.js文件中添加如下代码:

//获取原型对象上的push函数
const originalPush = Router.prototype.push
//修改原型对象中的push方法
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

原文链接:https://blog.csdn.net/weixin_42402845/article/details/108334329

点我评论
打赏本文
二维码


125

文章

14

标签

 访客统计  Update-******