Error: Avoided redundant navigation to current location: “/XXX“.的问题

2022-08-08,,,,

Error: Avoided redundant navigation to current location: “/XXX”

今天用vue的小demo,当我点击事件时,在浏览器上报如下错我,由于对前对不是很了解,一直找不到错在哪点,

进过一番百度一下,终于找到了解决的办法,这个错误时由于路由重复,解决办法:在vue项目下的router的index.js上,在代码里的Vue.use(Router)下面加上以下几行代码,大功告成:

/**
 * 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
 */
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

本文地址:https://blog.csdn.net/m0_45025997/article/details/107252926

《Error: Avoided redundant navigation to current location: “/XXX“.的问题.doc》

下载本文的Word格式文档,以方便收藏与打印。