-
Notifications
You must be signed in to change notification settings - Fork 0
/
29.动态路由匹配.html
38 lines (36 loc) · 897 Bytes
/
29.动态路由匹配.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>动态路由匹配</title>
</head>
<body>
<div id="app">
<p>
<router-link to="/user/foo">/user/foo</router-link>
<br><br>
<router-link to="/user/bar">/user/bar</router-link>
</p>
<router-view></router-view>
</div>
<script src="vue.2.5.js"></script>
<script src="vue-router.js"></script>
<script>
const User = {
template:`<div>{{$route.params.id}}</div>`
};
const router = new VueRouter({
routes:[
{
//路径参数使用冒号标记
path:'/user/:id',
component:User
}
]
});
const vm = new Vue({
router
}).$mount('#app');
</script>
</body>
</html>