为什么 vue-router 给我这个错误?需要明确的是,登录流程按预期工作,但我想 a) 摆脱 errro 和 b) 了解错误发生的原因。
错误:
Uncaught (in promise) Error: Redirected from "/login" to "/" via a navigation guard.
登录流程
登录操作:
doLogin({ commit }, loginData) {
commit("loginStart");
axiosClient
.post("/jwt-auth/v1/token", {
username: loginData.username,
password: loginData.password,
})
.then((response) => {
commit("loginStop", null);
commit("setUserData", response.data);
this.categories = airtableQuery.getTable("Categories");
commit("setCategories", this.categories);
this.locations = airtableQuery.getTable("Locations");
commit("setLocations", this.locations);
router.push("/"); // push to site root after authentication
})
.catch((error) => {
console.log(error.response.data.message);
commit("loginStop", error.response.data.message);
commit("delUserData"); …Run Code Online (Sandbox Code Playgroud)