forked from sunseekers/Vue2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue-routername.html
61 lines (60 loc) · 1.41 KB
/
vue-routername.html
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
60
61
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>给路由定义名字</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<div id="app">
<h1>Named Views</h1>
<ul>
<li>
<router-link to="/">/</router-link>
</li>
<li>
<router-link to="/other">/other</router-link>
</li>
</ul>
<router-view></router-view>
<router-view name="a"></router-view>
<router-view name="b"></router-view>
</div>
<script type="text/javascript" src='js/vue.min.js'></script>
<script type="text/javascript" src='js/vue-router.js'></script>
<script type="text/javascript">
const Foo = { template: '<div>11111</div>' }
const Bar = { template: '<div>22222</div>' }
const Baz = { template: '<div>33333</div>' }
const router = new VueRouter({
routes: [
{ path: '/',
components: {
default: Foo,
a: Bar,
b: Baz
}
},
{
path: '/other',
components: {
default: Baz,
a: Bar,
b: Foo
}
},
{
path:'*',redirect:'/'
}
]
})
new Vue({
router,
el: '#app'
})
</script>
</body>
</html>