NavigationDuplicated: Avoided re

2022-01-24  本文已影响0人  网恋被骗二块二

我的项目案例报错:NavigationDuplicated: Avoided redundant navigation to current location: "/discover/recommend".

翻译后为:NavigationDuplicated:避免了对当前位置的冗余导航:“/discover/recommend”。 大意是你娃点过了又老是点我的烦不烦(路由重复)。

解决:
在 src/router 目录下,找到你的路由配置文件,在这个位置贴上这个代码

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

即可解决,当时老师讲过这个问题,没有用心听,谨记!

百度的原文链接:NavigationDuplicated: Avoided redundant navigation to current location: “/“

上一篇下一篇

猜你喜欢

热点阅读