๋ฐ์ํ
1.
import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../components/Home.vue'
import About from '../components/About.vue'
Vue.use(VueRouter);
const routes = [
{
path: "/home",
name: "Home",
component: Home
},
{
path: "/about",
name: "About",
component: About
},
];
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router;
2.
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const routes = [
{
path: "/home",
component: () => import('../components/Home')
},
{
path: "/about",
component: () => import('../components/About')
}
];
const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes
})
export default router;
3.
import Vue from 'vue';
import VueRouter from 'vue-router';
import Home from '../components/Home.vue'
import About from '../components/About.vue'
Vue.use(VueRouter);
const router = new VueRouter({
routes: [
{path: '/home', component: Home},
{path: '/about', component: About},
],
mode: 'history',
base: process.env.BASE_URL,
})
export default router;
๋ฐ์ํ
'JavaScript > Vue' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Vue.js] v-bind ๋? (0) | 2021.12.28 |
---|---|
[Vue.js] ์ ์ธ ์์ (0) | 2021.10.25 |
[Vue.js] vue-router ์ด๋? (0) | 2021.10.25 |
@ : ์ ๋ ๊ฒฝ๋ก(root)๋ถํฐ ์์ (0) | 2021.10.22 |
Vue.js ๊ณต๋ถ 1์ผ์ฐจ (0) | 2021.10.18 |
๋๊ธ