vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/home”.
at createRouterError (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2066:15)
at createNavigationDuplicatedError (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2036:15)
at HTML5History.confirmTransition (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2329:18)
at HTML5History.transitionTo (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2261:8)
at HTML5History.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2602:10)
at eval (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:3027:22)
at new Promise ()
at VueRouter.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:3026:12)
at VueComponent.indexbtnClick (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js&:19:20)
at invokeWithErrorHandling (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1862:26)

解决方案1:

捕获异常

this.$router.push('/home').catch(err => console.log(err))

也可以不打印错误信息

this.$router.push('/home').catch(err => {})

解决方案2:

在跳转时,判断路由和当前路由是否一致,如果不一致再跳转
注意:this.$route.path可以获取到当前的路由路径(不是$.router)

  if (this.$route.path != '/home') {this.$router.push('/home')}

解决方案3:

在src–>router–>index.js添加代码:

const router = new VueRouter({routes,mode: 'history',// 修改linkActiveClasslinkActiveClass: 'active'})
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {return VueRouterPush.call(this, to).catch(err => err)
}

vue-router官网地址:https://router.vuejs.org/zh/

Vue-Router点击相同路由报错,vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated: Avoided r相关推荐

  1. 报错 | vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navig

    vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation ...

  2. vue-router报错的解决方法vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated:

    在main.js中加入以下代码 const originalPush = Router.prototype.push Router.prototype.push = function push(loc ...

  3. vue报错vue-router.esm.js?8c4f:2062 Uncaught (in promise) Error: Avoided redundant navigation to curren

    在写导航切换时点击会有以下报错 这个报错是是路由中点击路径重复 ,也有可能是安装的vue-router还是之前出错的那个版本,在项目目录下运行 npm i vue-router@3.0 -S 即可. ...

  4. Vue重复点击同一个路由报错问题解决

    在新版本的vue-router中,重复点击同一个路由会出现以下报错 : 这个问题时vue-router 3.2.0版本的一个小Bug 有三种解决办法: 第一种: vue-router降级处理(不推荐) ...

  5. vue报错 vue-router.esm.js?8c4f:2089 Uncaught (in promise)

    在main.js里面加上以下代码即可 import Router from 'vue-router'; const routerReplace = Router.prototype.replace; ...

  6. 解决Vue跳转到当前路由报错问题

    一.问题背景 官网首页Herder鼠标悬浮有很多二级页面,点击二级页面会进行跳转,当我已经在一个二级页面时,点击顶部导航中当前二级页面的其中一个状态(其实可以用三级页面,但是因为内容不多,我将一些内容 ...

  7. vue报错Uncaught (in promise) NavigationDuplicated:Avoided redundant navigation

    vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation ...

  8. 解决报错:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “

    报错内容: vue-router.esm.js?68cf:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navi ...

  9. 解决vue项目中重复点击导航路由报错

    vue版本 "vue": "^2.6.11", 主要代码 //重复点击导航路由报错 const originalPush = VueRouter.prototy ...

最新文章

  1. JVM-08垃圾收集Garbage Collection【GC常用参数】
  2. NYOJ-45 棋盘覆盖
  3. 我们如何意外地将Hibernate的JDBC流量增加了一倍
  4. python怎么启动mne_mne-python学习之一 入门介绍
  5. 用node-webkit把web应用打包成桌面应用
  6. 以社会工程学助力网络安全
  7. android定义dialog
  8. 拓端tecdat|通过SAS网络分析对人口迁移进行可视化分析
  9. python 谷歌翻译_Python:谷歌翻译20次的程序如何实现?
  10. 看书和写书,简单而复杂的反思-读书分享会感悟
  11. 一点点读懂thermal(一)
  12. IAR For ARM 历史版本下载链接
  13. 可配置组件库Fusion Design 了解一下
  14. 虚拟机由于硬盘存储空间过满导致启动异常+虚拟机扩容
  15. 6.存储结构与磁盘划分
  16. mysql多表查询注意事项_MySQL的多表查询
  17. 使用百度云同步盘和Git Extensions进行代码托管
  18. windows7经典开机音乐_糖豆人加入索尼克皮肤;三国群英传8上线Steam;疑似PS5开机音效...
  19. 【历史上的今天】4 月 6 日:小米正式成立;git 项目首次对外公开;将乔布斯赶出苹果的男人
  20. 【ubuntu】——安装wps

热门文章

  1. php护卫神5.3,护卫神·PHP套件[FastCGI],PHP5.3.28
  2. 分数的原码、反码、补码如何求
  3. mysql数据库迁移到达梦数据库
  4. 如何打造智能按摩椅?代码如何实现?
  5. Handlebars+tpl模块化开发html
  6. Computed property “addToCart“ was assigned to but it has no setter.
  7. SpringBoot 嵌入式Tomcat无法启动:Unable to start embedded Tomcat
  8. 近期交通部及各省市共发布5大重要政策全力推进智慧交通!
  9. 基于yolov5的Android版本目标检测app开发(部署安卓手机)
  10. interrupt java_关于java中的interrupt