Skip to content

Instantly share code, notes, and snippets.

@dewey92
Created March 3, 2016 07:17
Show Gist options
  • Save dewey92/99f1c4429f85fe806e6f to your computer and use it in GitHub Desktop.
Save dewey92/99f1c4429f85fe806e6f to your computer and use it in GitHub Desktop.
Vue router
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
Vue.use(require('vue-resource'))
const router = new VueRouter({
history : true,
saveScrollPosition: true
});
router.map({
'/all' : {
component(resolve) {
require(['../components/todo-list.vue'], resolve);
}
},
'/profile' : {
component(resolve) {
require(['../components/profile.vue'], resolve);
}
},
'*' : {
component(resolve) {
require(['../components/not-found.vue'], resolve);
}
}
});
// redirect
router.redirect({
'/': '/all',
});
const App = Vue.extend({});
router.start(App, '#app');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment