Skip to content

Commit c21fff4

Browse files
committed
add demo2
1 parent da227ed commit c21fff4

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

vue-router-demo/demo2.html

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>String——http://www.itstrive.com</title>
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
7+
<meta name="apple-mobile-web-app-capable" content="yes">
8+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
9+
<style>
10+
.v-link-active{
11+
color: #f60;
12+
font-size: 20px;
13+
}
14+
</style>
15+
<script src="vue.js"></script>
16+
<script src="vue-router.js"></script>
17+
18+
</head>
19+
<body>
20+
<div id="box">
21+
<ul>
22+
<li>
23+
<a v-link="{path:'/home'}">主页</a>
24+
</li>
25+
<li>
26+
<a v-link="{path:'/news'}">新闻</a>
27+
</li>
28+
</ul>
29+
<router-view></router-view>
30+
</div>
31+
32+
<template id="home_tpl">
33+
<h1>我是主页</h1>
34+
<div>
35+
<a v-link="{path:'/home/login'}">用户登录</a>
36+
<a v-link="{path:'/home/reg'}">用户注册</a>
37+
</div>
38+
<router-view></router-view>
39+
</template>
40+
41+
<template id="news_tpl">
42+
<h3>我是新闻页面</h3>
43+
<div>
44+
<a v-link="{path:'/news/detail/001'}">新闻001</a>
45+
<a v-link="{path:'/news/detail/002'}">新闻002</a>
46+
</div>
47+
<router-view></router-view>
48+
</template>
49+
50+
<template id="detail_tpl">
51+
<div style="width:200px; height: 200px; border:1px solid #000;">
52+
{{$route.params.id}}
53+
</div>
54+
</template>
55+
56+
<script>
57+
var Home=Vue.extend({
58+
template:'#home_tpl'
59+
});
60+
61+
var News=Vue.extend({
62+
template:'#news_tpl'
63+
});
64+
65+
var Login=Vue.extend({
66+
template:'<strong>我是用户登录</strong>'
67+
});
68+
69+
var Reg=Vue.extend({
70+
template:'<em>我是用户注册</em>'
71+
});
72+
73+
var Detail=Vue.extend({
74+
template:'#detail_tpl'
75+
});
76+
77+
78+
var App=Vue.extend({});
79+
80+
var router=new VueRouter();
81+
82+
router.map({
83+
'/home':{
84+
component:Home,
85+
subRoutes:{
86+
'login':{
87+
component:Login
88+
},
89+
'reg':{
90+
component:Reg
91+
}
92+
}
93+
},
94+
'/news':{
95+
component:News,
96+
subRoutes:{
97+
'detail/:id':{
98+
component:Detail
99+
}
100+
}
101+
}
102+
});
103+
104+
router.start(App,'#box');
105+
</script>
106+
</body>
107+
</html>
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+

0 commit comments

Comments
 (0)