关于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)
}

ok,这样就完美解决了!有什么疑问,可以留言哦。

Logo

前往低代码交流专区

更多推荐