Skip to content

Instantly share code, notes, and snippets.

@blogui91
Created September 10, 2017 20:59
Show Gist options
  • Save blogui91/5f7e8974054310b29de96f46ebde71c0 to your computer and use it in GitHub Desktop.
Save blogui91/5f7e8974054310b29de96f46ebde71c0 to your computer and use it in GitHub Desktop.
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
function load (component) {
// '@' is aliased to src/components
return () => import(`@/${component}.vue`)
}
//We create this function to point to Views folder
function loadView(component) {
// '@' is aliased to src/components
return () => import(`src/views/${component}.vue`)
}
export default new VueRouter({
/*
* NOTE! VueRouter "history" mode DOESN'T works for Cordova builds,
* it is only to be used only for websites.
*
* If you decide to go with "history" mode, please also open /config/index.js
* and set "build.publicPath" to something other than an empty string.
* Example: '/' instead of current ''
*
* If switching back to default "hash" mode, don't forget to set the
* build publicPath back to '' so Cordova builds work again.
*/
routes: [
{ path: '/', component: load('Hello') },
{ path: '/login', component: loadView('Login') }, //Login Route
// Always leave this last one
{ path: '*', component: load('Error404') } // Not found
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment