-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue_router_08.html
66 lines (66 loc) · 1.36 KB
/
vue_router_08.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
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="container">
<h3>VueRouter--别名</h3>
<div>
<router-link to="/first">First Link</router-link>
<br>
<router-link to="/second">Second Link</router-link>
<br>
<router-link to="/t">Third Link</router-link>
</div>
<router-view></router-view>
</div>
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-router"></script>
<script>
const firstComponent = {
template: "<div>this is the first component</div>"
};
const secondComponent = {
template: "<div>this is the second component</div>"
};
const fourthComponent = {
template: "<div>this is the fourth component</div>"
};
var myRoutes = [
{
name: "first_route",
path: "/first",
alias: "/f",
component: firstComponent
},
{
name: "second_route",
path: "/second",
alias: "/s",
redirect: "/first"
},
{
name: "third_route",
path: "/third",
alias: "/t",
redirect: {name: "fourth_route"}
},
{
name: "fourth_route",
path: "/fourth",
component: fourthComponent
}
];
var myRouter = new VueRouter({
mode: "history",
routes: myRoutes
});
var myapp = new Vue({
router: myRouter,
el: "#container"
});
</script>
</body>
</html>