Created
May 23, 2021 21:04
-
-
Save frankyonnetti/3f76e57896051e7cb38c1ca9fba13ad3 to your computer and use it in GitHub Desktop.
Vue - router #vue2 #router
This file contains hidden or 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
| <template> | |
| <div id="frontend-guide"> | |
| <h1>Front-end Guide</h1> | |
| <router-link to="/frontend-guide/buttons">Buttons</router-link> | |
| <router-link to="/frontend-guide/grid">Grid</router-link> | |
| <!-- children routes work here --> | |
| <router-view/> | |
| </div> | |
| </template> |
This file contains hidden or 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
| // https://jsfiddle.net/yyx990803/L7hscd8h/ | |
| // fork: https://jsfiddle.net/frankyonnetti/2vfq30xs/ | |
| import Vue from 'vue' | |
| import VueRouter from 'vue-router' | |
| Vue.use(VueRouter) | |
| const routes = [ | |
| { | |
| path: '/', | |
| name: 'Home', | |
| component: () => import('../views/Home.vue') | |
| }, | |
| { | |
| path: '/frontend-guide', | |
| name: 'FrontendGuide', | |
| component: () => import('../views/FrontendGuide.vue'), | |
| // children within FrontendGuide <router-view>. | |
| children: [ | |
| { | |
| path: 'buttons', | |
| name: 'Buttons', | |
| component: () => import('../views/Buttons.vue') | |
| }, | |
| { | |
| path: 'grid', | |
| name: 'Grid', | |
| component: () => import('../views/Grid.vue') | |
| } | |
| ] | |
| } | |
| ] | |
| const router = new VueRouter({ | |
| mode: 'history', | |
| routes | |
| }) | |
| export default router |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment