vue.js - 当我在登录操作后尝试推送时,出现意外错误
问题描述
我在登录操作后将 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();
}
});
解决方案
推荐阅读
- node.js - MongoError:写入批量大小必须在 1 到 100000 之间。得到 0 个操作
- mongodb - 从另一个更新集合需要太长时间
- python - 使用 joblib 的全局对象
- android - 如何以所有设备看起来都相同的边距定位视图?
- pandas - 无法更改 Pandas Groupby 对象
- python - 如何从输入子网列表中检索未使用的子网
- c++ - 为不断变化但只读的模型子类化 QAbstractListModel 的正确方法是什么?
- c# - Botframework(V4 预览版)更新的对话状态值未在对话中保留
- c# - IIS 在浏览器中显示文件。我该如何防止这种情况?
- java - 如何使用 Selenium 将数据保存到文件中