Feat: Add router

This commit is contained in:
jhynsoo 2024-05-13 14:34:54 +09:00
parent aedf8f5824
commit 4f205b15e5

View File

@ -1,5 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router'; import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '../views/HomeView.vue'; import HomeView from '@/views/HomeView.vue';
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
@ -10,26 +10,23 @@ const router = createRouter({
component: HomeView, component: HomeView,
}, },
{ {
path: '/article', path: '/board',
name: 'article', component: () => import('@/views/BoardView.vue'),
//index.html이 화면에 표시될때 미리 다운 받지 않고 필요시 동적으로 페이지를 다운 받는다.
component: () => import('@/views/ArticleView.vue'),
redirect: { name: 'article-list' },
children: [ children: [
{ {
path: 'list', //children은 /를 자동으로 붙여 주므로 빼야 한다. path: '',
name: 'article-list', name: 'board',
component: () => import('@/components/article/ArticleList.vue'), component: () => import('@/components/article/ArticleList.vue'),
}, },
{ {
path: 'regist', path: '/article/:id',
name: 'article-regist', name: 'article',
component: () => import('@/components/article/ArticleRegist.vue'), component: () => import('@/components/article/ArticleDetail.vue'),
}, },
{ {
path: 'detail', path: '/article/form',
name: 'article-detail', name: 'article-create',
component: () => import('@/components/article/ArticleDetail.vue'), component: () => import('@/components/article/ArticleForm.vue'),
}, },
], ],
}, },