我在登录操作后将 vuejs 与 vuex 一起使用我试图推送到仪表板页面,但是它是如何抛出这个错误的
Uncaught (in promise) Error: Redirected when going from "/signin?redirect=%2F" to "/" via a navigation guard.
以下是我要推送到仪表板的路由器文件
const routes = [
{
path: "/signin",
name: "signin",
component: () => import("../components/Authentication/Signin.vue"),
},
{
path: "/",
name: "dashboard",
component: () => import("../components/Dashboard/Dashboard.vue"),
meta: {
requiresAuth: true,
},
},
];
router.beforeEach((to, from, next) => {
if (to.name == "dashboard" && to.meta.requiresAuth && token == null) {
console.log(token);
next({
path: "/signin",
query: {
redirect: to.fullPath,
},
});
} else if (to.name == "signin" && token != null) {
console.log("signin");
next("/");
} else {
console.log("else");
next();
}
});