Redirected when going from “/login?redirect=%2Fabout“ to “/“ via 登录后就报错

您所在的位置:网站首页 jsreplace方法 Redirected when going from “/login?redirect=%2Fabout“ to “/“ via 登录后就报错

Redirected when going from “/login?redirect=%2Fabout“ to “/“ via 登录后就报错

2023-06-25 16:40| 来源: 网络整理| 查看: 265

参考链接:https://blog.csdn.net/qq_42805569/article/details/111238634 原因:vue-router路由版本更新产生的问题,导致路由跳转失败抛出该错误,但并不影响程序功能 解决方案一、 使用编程式导航跳转时,每次使用,后面都跟上.catch方法,捕获错误信息

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

解决方案二、 全局解决:替换路由的Push和replace方法,放在src/router/index.js中:

import Router from 'vue-router' const originalPush = Router.prototype.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) }


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3