解决"Uncaught (in promise) Error: Navigation cancelled from "/" to "/login" with a new navigation"报错处理
Uncaught (in promise) Error: Navigation cancelled from “/” to “/login” with a new navigation.
这个错误是vue-router内部错误,没有进行catch处理,导致的编程式导航跳转问题,往同一地址跳转时会报错的情况。
push和replace 都会导致这个情况的发生。

解决方法如下:
在路由器中进行配置:router/index.js
import Vue from 'vue'
import Router from 'vue-router' Vue.use(Router)
// 解决报错
const originalPush = Router.prototype.push
const originalReplace = Router.prototype.replace
// push
Router.prototype.push = function push (location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
// replace
Router.prototype.replace = function push (location, onResolve, onReject) {
if (onResolve || onReject) return originalReplace.call(this, location, onResolve, onReject)
return originalReplace.call(this, location).catch(err => err)
}
仅在此记录一下遇到的问题和最后的解决办法,亲测可用。
解决"Uncaught (in promise) Error: Navigation cancelled from "/" to "/login" with a new navigation"报错处理的更多相关文章
- Ionic3报错Error: Uncaught (in promise): Error: StaticInjectorError
ERROR Error: Uncaught (in promise): Error: StaticInjectorError[Geolocation]: StaticInjectorError[Geo ...
- axios请求报Uncaught (in promise) Error: Request failed with status code 404
使用axios处理请求时,出现的问题解决 当url是远程接口链接时,会报404的错误: Uncaught (in promise) Error: Request failed with status ...
- Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty 报错
项目中遇到的获取https的数据接口数据时,Unexpected error: java.security.InvalidAlgorithmParameterException: the trustA ...
- 解决Error: ENOENT: no such file or directory, scandir 安装node-sass报错
新项目开发需要安装依赖,但是安装完之后通过gulp运行项目,产生了一下的报错: 解决方案是执行一些方法: npm rebuild node-sass 可是有时就是网络问题导致上面命令安装失败,查下失败 ...
- (未解决)flume监控目录,抓取文件内容推送给kafka,报错
flume监控目录,抓取文件内容推送给kafka,报错: /export/datas/destFile/220104_YT1013_8c5f13f33c299316c6720cc51f94f7a0_2 ...
- 解决liblapack.so.3: cannot open shared object file: No such file or directory报错
关于这种类型的报错通常的解决方式有两个: 方法一.查找系统哪儿有liblapack.so.3这个文件 find /lib -name liblapack.so.3 如果lib找不到这个文件,请换其他路 ...
- 解决Requests中文乱码【有用】,读取htm文件 读取txt文件报错:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc8 in position 0
打开这个网址https://blog.csdn.net/chaowanghn/article/details/54889835 python在open读取txt文件时,出现UnicodeDecodeE ...
- 解决incorrect 'only available in ES6' warning (W119) with options `moz: true, esversion: 6` 报错问题
很多同学在新建vue项目时,会遇到 incorrect 'only available in ES6' warning (W119) with options `moz: true, esversio ...
- Angular项目 Error: [ngRepeat:dupes] Duplicates in a repeater are not allowed.报错
在angular的项目里,一不小心就会出现这个错误[ngRepeat:dupes] ,这个问题是因为内容有重复引起的解决起来挺简单 在对应的ng-repeat指令中增加track by $index, ...
随机推荐
- Python+flask+flask-apscheduer实现定时下发任务
Python+flask+flask-apscheduer实现定时下发任务 背景: 使用python+flask+mamaca实现的自动化用例管理平台,可以下发任务到具体的节点,进行执行测试用例,没有 ...
- Appium服务器初始化参数(Capability)
原文:https://blog.csdn.net/lilongsy/article/details/83010101 appium官方说明:https://appium.io/docs/cn/writ ...
- Python_列表比较大小
比较原理 从第一个元素顺序开始比较,如果相等,则继续,返回第一个不相等元素得比较结果.如果所有元素比较均相等,则长的列表大,一样长则两列表相等. 示例 a = [5, 6, 3] b = [5, 4, ...
- 初识python:scoket 单用户互发消息
实现功能: 启动"服务器".通过"客户端1"连接"服务器",然后互发消息.在此过程中,有"客户端2"连接到"服 ...
- Pytest_参数化(10)
pytest参数化有两种方式: mark的parametrize标记:@pytest.mark.parametrize(变量名,变量值),其中变量值类型为列表.元组或其它可迭代对象. fixture的 ...
- 基于appnium+python+夜神模拟器的自动化
首先搭好appnium环境!参考https://www.cnblogs.com/testlearn/p/11419797.html 1.安装夜神模拟器 下载安装夜神模拟器后,在cmd命令输入adb c ...
- python 单下划线与双下划线的区别
来自为知笔记(Wiz)
- 异常 finally
经典面试题: 程序执行结果是100: (一):final和finally和finalize的区别
- StringBuffer和String的区别
面试题:String为什么不可变 StringBuffer和StringBuilder的区别 String 和StringBuffer的区别: (一):String 类中的byte数组使用final修 ...
- RBAC: K8s基于角色的权限控制
文章目录 RBAC: K8s基于角色的权限控制 ServiceAccount.Role.RoleBinding Step 1:创建一个ServiceAccount,指定namespace Step 2 ...