学无先后,达者为师

网站首页 编程语言 正文

Uncaught (in promise) Error: Redirected when going from “xxx“ to “xxx“ via a navigation guard.

作者:Pisces_224 更新时间: 2022-02-27 编程语言

原因

涉及到关于重定向的问题,虽然对正常功能没影响,但是看着浏览器控制台报错,就不爽。查了资料,他们都说是加个catch抛出异常:

created() {
    const { params, query } = this.$route
    const { path } = params
    this.$router.replace({ path: '/' + path, query })
    .catch(() => {});   // 触发路由导航重定向,把error抛出来,否则浏览器控制台报错(虽然没影响)
  },

但好像没啥作用。。

先记录一下,后续有时间琢磨。

参考博客:Vue router升级导致的错误

原文链接:https://blog.csdn.net/qq_36256590/article/details/120017821

栏目分类
最近更新