vue编程式路由跳转统一页面报错,处理方案

先上报错

解决方案:

javascript 复制代码
//1:缓存原始的plus.push
const originalPush = VueRouter.prototype.push;

//2:增强plus.push.
VueRouter.prototype.push = function(location, okCallBack, errCallBack) {
	//没有成功,失败的回调, 那就使用catch
	if (okCallBack === undefined && errCallBack === undefined) {
		return originalPush.call(this, location).catch(() => {});
	} else {
		//如果有了成功,失败的回调,那就使用传过来的成功跟回调
		return originalPush.call(this, location, okCallBack, errCallBack).catch(() => {});
	}
}
相关推荐
wangruofeng28 分钟前
Phosphor Icons 官网源码拆解:URL 即存储、水波动画与 7362 Star 图标库的架构实践
前端·架构·github
BigTopOne1 小时前
WebRTC Native / Android 开发学习资源整理
前端
excel2 小时前
nuxt 3 升级 nuxt 4 报错之 hasInjectionContext
前端
何以解忧,唯有..2 小时前
LangChain 工具调用(Tool Calling)实战指南
java·前端·langchain
软件聚导航3 小时前
「聚小软 AI 助手」技术升级:从数据库检索到 RAG 知识库问答
前端·数据库·mysql·微信小程序·小程序·ai编程·rag
恋猫de小郭3 小时前
看懂大模型架构术语,帮助你理解目前常见的大模型开源架构
前端·人工智能·ai编程
yma164 小时前
通过提示词实现GitHub Pages 和 Nginx 双部署竟然这么简单?
前端
前端 贾公子4 小时前
第09章:上下文与记忆 (2)
java·服务器·前端
可乐鸡翅yeah_4 小时前
第三方接口对接 M3U8 流媒体排坑实战,解决外部服务商流兼容难题
前端·javascript·python·django·html·m3u8·m3u8在线
GoppViper4 小时前
RDF资源描述框架深度解析:语义Web的数据基石与实战逻辑
前端·数据库