zoukankan      html  css  js  c++  java
  • Uncaught (in promise) Error: Redirected when going from "/login" to "/home" via a navigation guard.

    项目中遇到如下报错内容:Uncaught (in promise) Error: Uncaught (in promise) Error: Redirected when going from "/login" to "/home" via a navigation guard.

    原因:vue-router路由版本更新产生的问题,导致路由跳转失败抛出该错误,但并不影响程序功能

    解决方案一、

    使用编程式导航跳转时,每次使用,后面都跟上.catch方法,捕获错误信息

    this.$router.push('/location').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)
    }

     转载:https://blog.csdn.net/qq_42805569/article/details/111238634 感谢大佬!

     
  • 相关阅读:
    对坐标点的离散化
    线段树-离散化处理点
    树状数组
    线段树
    dfs
    vector
    go 参数传递的是值还是引用 (转)
    go 数组指针 指针数组
    go 协程
    go 接口实现
  • 原文地址:https://www.cnblogs.com/hudaxian/p/14620617.html
Copyright © 2011-2022 走看看