Vue-Router点击相同路由报错,vue-router.esm.js?8c4f:2065 Uncaught (in promise) NavigationDuplicated: Avoided r
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相关推荐
- 报错 | 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 ...
- 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 ...
- 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 即可. ...
- Vue重复点击同一个路由报错问题解决
在新版本的vue-router中,重复点击同一个路由会出现以下报错 : 这个问题时vue-router 3.2.0版本的一个小Bug 有三种解决办法: 第一种: vue-router降级处理(不推荐) ...
- vue报错 vue-router.esm.js?8c4f:2089 Uncaught (in promise)
在main.js里面加上以下代码即可 import Router from 'vue-router'; const routerReplace = Router.prototype.replace; ...
- 解决Vue跳转到当前路由报错问题
一.问题背景 官网首页Herder鼠标悬浮有很多二级页面,点击二级页面会进行跳转,当我已经在一个二级页面时,点击顶部导航中当前二级页面的其中一个状态(其实可以用三级页面,但是因为内容不多,我将一些内容 ...
- vue报错Uncaught (in promise) NavigationDuplicated:Avoided redundant navigation
vue-router.esm.js?3423:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation ...
- 解决报错:Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “
报错内容: vue-router.esm.js?68cf:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navi ...
- 解决vue项目中重复点击导航路由报错
vue版本 "vue": "^2.6.11", 主要代码 //重复点击导航路由报错 const originalPush = VueRouter.prototy ...
最新文章
- JVM-08垃圾收集Garbage Collection【GC常用参数】
- NYOJ-45 棋盘覆盖
- 我们如何意外地将Hibernate的JDBC流量增加了一倍
- python怎么启动mne_mne-python学习之一 入门介绍
- 用node-webkit把web应用打包成桌面应用
- 以社会工程学助力网络安全
- android定义dialog
- 拓端tecdat|通过SAS网络分析对人口迁移进行可视化分析
- python 谷歌翻译_Python:谷歌翻译20次的程序如何实现?
- 看书和写书,简单而复杂的反思-读书分享会感悟
- 一点点读懂thermal(一)
- IAR For ARM 历史版本下载链接
- 可配置组件库Fusion Design 了解一下
- 虚拟机由于硬盘存储空间过满导致启动异常+虚拟机扩容
- 6.存储结构与磁盘划分
- mysql多表查询注意事项_MySQL的多表查询
- 使用百度云同步盘和Git Extensions进行代码托管
- windows7经典开机音乐_糖豆人加入索尼克皮肤;三国群英传8上线Steam;疑似PS5开机音效...
- 【历史上的今天】4 月 6 日:小米正式成立;git 项目首次对外公开;将乔布斯赶出苹果的男人
- 【ubuntu】——安装wps
热门文章
- php护卫神5.3,护卫神·PHP套件[FastCGI],PHP5.3.28
- 分数的原码、反码、补码如何求
- mysql数据库迁移到达梦数据库
- 如何打造智能按摩椅?代码如何实现?
- Handlebars+tpl模块化开发html
- Computed property “addToCart“ was assigned to but it has no setter.
- SpringBoot 嵌入式Tomcat无法启动:Unable to start embedded Tomcat
- 近期交通部及各省市共发布5大重要政策全力推进智慧交通!
- 基于yolov5的Android版本目标检测app开发(部署安卓手机)
- interrupt java_关于java中的interrupt