Skip to content

Instantly share code, notes, and snippets.

@as27
Created February 11, 2017 10:07
Show Gist options
  • Save as27/481a1c583cc042f0eee3ade98f0f19c8 to your computer and use it in GitHub Desktop.
Save as27/481a1c583cc042f0eee3ade98f0f19c8 to your computer and use it in GitHub Desktop.
const Home = Vue.component('home',{
data : () => {
return {
a: "1",
collections : {}
}
},
template: `<div><h1>Home</h1><router-view></router-view></div>`,
mounted: () => {
var data = {};
Vue.http.get('/collection').then(
(res) => {
data = res.body;
console.log(res.body);
}
);
this.collections = data;
}
})
const Collection = Vue.component('collection',{
template: `<div><h2>Collection</h2><router-view></router-view></div>`
})
const Item = Vue.component('collection',{
template: `<div><h3>Item</h3><router-view></router-view></div>`
})
const routes = [
{
path: '/',
component: Home,
children: [
{
path: ':cid',
component: Collection,
children: [
{
path: ':iid',
component: Item
}
]
}]
},
]
const router = new VueRouter({
routes: routes
})
const app = new Vue({
router
}).$mount('#app')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment