import { createMemoryHistory, createRouter } from "vue-router";
import { AuthUser } from "../../auth/user";
const routes = [
{
path: "/",
component : () => import("../components/Home/Home.vue"),
beforeEnter : (to, from, next)=>{
if(!AuthUser()){
next({path : "/signup"})
}else{
next()
return ""
}
}
},
{
path: "/signup",
component : () => import("@/components/Signup/Signup.vue"),
}
];
const router = createRouter({
history: createMemoryHistory(),
routes,
});
export default router
我不知道为什么当我打开"/"时,组件注册显示,但网址"http://localhost:3000/"根本没有改变.
它完美地显示了组件,问题在于网址.
Authuser目前始终返回true.