-
Vue.js) vue-router 설정 방법Programing Language/Vue.js 2021. 4. 27. 20:44728x90반응형This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
//vue-router설정 /** * 1. main.js 설정 * path: frontend/src/main.js */ import { createApp } from 'vue' import App from './App.vue' import router from './router' createApp(App).use(router).mount('#app') /******************************************************************/ /** * 2. app.vue 설정 * path: /frontend/src/App.vue */ <template> <router-view></router-view> <!-- :~~<- 붙일때는 무조건 붙여서 사용해야한다. --> </template> <script> export default { name: "App", components: {}, }; </script> <style scoped> </style> /******************************************************************/ /** * 3. index.js 설정 * 3.1 router폴더 생성 * path: frontend/src/router /index.js */ import {createRouter, createWebHistory} from 'vue-router' import Home from '../views/Home' import notHome from '../views/notHome' import e404 from '../views/e404' const routes = [ { path:'/', name:'Home', component: Home }, { path:'/nothome', name: 'nothome', component: notHome }, { path:'/:pathMatch(.*)', name: 'e404', component: e404 } ] const router = createRouter({ history: createWebHistory(process.env.BASE_URL), //history: createWebHashHistory(), routes, }) export default router 728x90반응형'Programing Language > Vue.js' 카테고리의 다른 글
Vue.js) express에 vue.js 배포할때 vue.config.js 파일코드 (0) 2021.05.25 Vue.js) Invalid Host header 에러 발생을때 (0) 2021.05.25 Vue.js) vue-router로 앱 배포후 404에러 캐치하기. (0) 2021.04.18 Vue.js) vue.js 설치 (0) 2021.04.18 Vue.js) Vue.js + express 로 풀스택 웹 배포하기 (2) 2021.04.18