-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp2.js
58 lines (53 loc) · 1.12 KB
/
app2.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
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const Log = {
template: `<div class="log">id: {{ $route.params.id }}, type: {{ $route.params.type }}</div>`
}
const Logs = {
template: `
<div>
<pre id="params">{{ to.params }}</pre>
<router-link :to="to" class="child-link">{{ to.params.type }}</router-link>
<router-view></router-view>
</div>
`,
data () {
return {
to: {
name: 'items.logs.type',
params: { type: 'info' }
}
}
}
}
const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{
path: '/items/:id/logs',
component: Logs,
children: [
{
path: ':type',
name: 'items.logs.type',
component: Log
}
]
}
]
})
new Vue({
router,
template: `
<div id="app">
<h1>Route params</h1>
<ul>
<li><router-link to="/items/1/logs">item #1</router-link></li>
<li><router-link to="/items/2/logs">item #2</router-link></li>
</ul>
<router-view class="view"></router-view>
</div>
`
}).$mount('#app')