解决"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, ...
随机推荐
- C#中的记录(record)
从C#9.0开始,我们有了一个有趣的语法糖:记录(record) 为什么提供记录? 开发过程中,我们往往会创建一些简单的实体,它们仅仅拥有一些简单的属性,可能还有几个简单的方法,比如DTO等等,但是这 ...
- VirtualBox 虚拟机怎样设置共享文件夹
首次在VirtualBox装完系统后,很经常用到的操作就是:想将主机的东西拉倒虚拟机进行使用或安装,那怎么将主机的文件拿到虚拟机呢? 1.在虚拟机 > 设置中选择 >安装增强功能,经过这个 ...
- epoll实现原理
作者:蓝形参链接:https://www.zhihu.com/question/20122137/answer/14049112来源:知乎 首先我们来定义流的概念,一个流可以是文件,socket,pi ...
- minio实现文件上传下载和删除功能
https://blog.csdn.net/tc979907461/article/details/106673570?utm_medium=distribute.pc_relevant_t0.non ...
- SQL Server数据库出现“无法访问数据库XXX(objectExplorer)”的解决办法
数据库版本为2008R2,服务器异常重启并重新挂载iscsi后,数据库出现"无法访问数据库XXX(objectExplorer)"问题. 输入SQL命令查看数据库状态 1 sele ...
- Android官方文档翻译 五 1.3Building a Simple User Interface
Building a Simple User Interface 创建一个简单的用户界面 This lesson teaches you to 这节课将教给你: Create a Linear Lay ...
- Discuz!X V3.4后台任意文件删除
Discuz!X V3.4后台任意文件删除 简述 该漏洞为后台任意文件删除,需要有管理员的权限,所以说危害非常小 复现环境 docker.vulhub-master 项目地址:https://gite ...
- C#图片转成流
Bitmap b = new Bitmap(Server.MapPath(ppath)); Stream ms = new MemoryStream(); b.Save(ms, System.Draw ...
- UML 有关类图知识及类间关系
原文链接:https://blog.csdn.net/mj_ww/article/details/53020346 1. 类的含义 类图(Class diagram)显示了系统的静态结构,而系统的静态 ...
- 【刷题-PAT】A1111 Online Map (30 分)
1111 Online Map (30 分) Input our current position and a destination, an online map can recommend sev ...