
File name
Commit message
Commit date
File name
Commit message
Commit date
File name
Commit message
Commit date
import { createWebHistory, createRouter } from "vue-router";
// 공통페이지
import Login from "./login/Login.vue";
import MyInfo from "./user/MyInfo.vue";
import Main from "./main/Main.vue";
import NotFound from "./etc/NotFound.vue";
const routes = [
{ path: "/", name: "MainPage", component: Main },
{ path: "/Login.page", name: "Login", component: Login },
{ path: "/MyInfo.page", name: "MyInfo", component: MyInfo },
{ path: "/notFound.page", name: "NotFoundPage", component: NotFound },
];
const AppRouter = createRouter({
history: createWebHistory(),
routes,
// 모든 라우트 이동 후 페이지 상단으로 스크롤
scrollBehavior() {
return { top: 0 }
},
});
AppRouter.beforeEach((to, from, next) => {
const routeExists = AppRouter.getRoutes().some(route => route.path === to.path || (route.name && route.name === to.name));
if (!routeExists) {
next({ name: 'NotFoundPage' });
return;
}
next();
});
export default AppRouter;