Last active
February 1, 2017 19:57
-
-
Save maxmckenzie/6a35c578be703fdc66556b468a2b3237 to your computer and use it in GitHub Desktop.
Vue webpack Vue-router configuration (Standard JS Style)
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
// src/App.vue | |
<template> | |
<div> | |
<div class="menu"> | |
<router-link :to=" { name: 'home' }">Home</router-link> | |
<router-link :to=" { name: 'auth' }">Auth</router-link> | |
</div> | |
<div id="app"> | |
<router-view></router-view> | |
</div> | |
</div> | |
</template> | |
<script> | |
import Hello from './components/Hello' | |
export default { | |
name: 'app', | |
components: { | |
Hello | |
} | |
} | |
</script> |
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
/* eslint-disable no-new */ | |
import Vue from 'vue' | |
import VueRouter from 'vue-router' | |
import App from './App' | |
Vue.use(VueRouter) | |
const router = new VueRouter({ | |
mode: '', | |
// https://router.vuejs.org/en/essentials/history-mode.html | |
routes: [{ | |
path: '/', | |
name: 'home', | |
component: function (resolve) { | |
require(['./components/Hello.vue'], resolve) | |
} | |
}, { | |
path: '/auth', | |
name: 'auth', | |
component: function (resolve) { | |
require(['./components/Auth.vue'], resolve) | |
} | |
}, { | |
path: '*', | |
name: '404', | |
component: function (resolve) { | |
require(['./components/404.vue'], resolve) | |
} | |
}] | |
}) | |
new Vue({ | |
el: '#app', | |
router, | |
template: '<App/>', | |
components: { App } | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment