1<body>
2 <div id="app"></div>
3 <script>
4 const Home = { template: `<h1>Home</h1>` }
5 const NewestComments = { template: `<h3>Newest Comments</h3>` }
6 const TopComments = { template: `<h3>Top Comments</h3>` }
7 const SearchResults = { template: `<h3>Search Results</h3>` }
8 const TopBar = { template: `<h3>Topbar</h3>` }
9 const NavBar = { template: `<h3>Navbar</h3>` }
10 const VideoDetail = { template: `<div>Video Details <router-view />
11 </div>` }
12
13 const routes = [
14 { path: '/', component: Home },
15 {
16 path: '/video/:id',
17 component: VideoDetail,
18 props: true,
19 children: [
20 { path: 'comments/top', component: TopComments },
21 { path: 'comments/newest', component: NewestComments }
22 ]
23 },
24 { path: '/search/:query', component: SearchResults, props: true }
25 ];
26
27 new Vue({
28 el: '#app',
29 template: `<div>
30 <TopBar />
31 <NavBar />
32 <router-view />
33 </div>`,
34 router: new VueRouter({ routes }),
35 components: { TopBar, NavBar }
36 })
37 </script>
38</body>