NavigationDuplicated: Avoided redundant navigation to current location(路由跳转到当前页面报错)

记录一下我又发现了一个新的报错,准确说是warning,不影响你使用但是留着它影响心情,原因是我的路由跳转到了当前页面,下面是报错截图,解决方法在图片后面。
在这里插入图片描述
在这里插入图片描述

只需要在你的router.js也就是路由配置文件下加入下面这段代码即可,注意Router是你实例化的路由对象,版本不同有可能是VueRouter,添加后问题解决。

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

猜你喜欢

转载自blog.csdn.net/qq_43511063/article/details/109906077
今日推荐