vue-router — Uncaught (in promise) Error: Redirected from “/login” to “/” via a navigation guard

后端 未结 6 1506
孤城傲影
孤城傲影 2020-12-11 14:38

Why is vue-router giving me this error? To be clear, the login flow works as intended but I want to a) get rid of the errro and b) understand why the error is happening.

6条回答
  •  攒了一身酷
    2020-12-11 15:32

    If your redirect is after a call to router.push('/someroute) then you can catch this error as router.push() is a promise and you can attach a catch to it as below

    $router.push('/somesecureroute')
    .catch(error => {
       console.info(error.message)
    })
    

提交回复
热议问题