forked from vuejs/vue-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
59 lines (52 loc) · 1.22 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const Wrap = { template: '<div>child: <router-view></router-view></div>' }
const Index = {
template: '<wrap />',
components: {
Wrap
}
}
const IndexChild1 = { template: '<div class="current">index child1</div>' }
const IndexChild2 = { template: '<div class="current">index child2</div>' }
const Home = { template: '<div class="current">home</div>' }
const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{
path: '/index',
component: Index,
children: [
{
path: 'child1',
component: IndexChild1
},
{
path: 'child2',
component: IndexChild2
}
]
},
{
path: '/home',
component: Home
}
]
})
new Vue({
router,
template: `
<div id="app">
<ul>
<li><router-link tag="a" to="/index/child1">index child 1</router-link></li>
<li><router-link tag="a" to="/index/child2">index child 2</router-link></li>
<li><router-link tag="a" to="/home">home</router-link></li>
</ul>
<keep-alive>
<router-view></router-view>
</keep-alive>
</div>
`
}).$mount('#app')