Created
February 11, 2017 10:07
-
-
Save as27/481a1c583cc042f0eee3ade98f0f19c8 to your computer and use it in GitHub Desktop.
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
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