-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue_router_07.html
62 lines (62 loc) · 1.29 KB
/
vue_router_07.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
<!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="/third">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",
component: firstComponent
},
{
name: "second_route",
path: "/second",
redirect: "/first"
},
{
name: "third_route",
path: "/third",
redirect: {name: "fourth_route"}
},
{
name: "fourth_route",
path: "/fourth",
component: fourthComponent
}
];
var myRouter = new VueRouter({
routes: myRoutes
});
var myapp = new Vue({
router: myRouter,
el: "#container"
});
</script>
</body>
</html>