@@ -11,14 +11,27 @@ function dynamicPropsFn (route) {
11
11
}
12
12
}
13
13
14
+ const Child = {
15
+ name : 'child' ,
16
+ props : { name : { default : 'name' } } ,
17
+ template : `<div><h2 class="hello">Hello {{ name }}</h2></div>`
18
+ }
19
+
20
+ const Parent = {
21
+ name : 'parent' ,
22
+ components : { Child } ,
23
+ template : `<child v-bind="$attrs"></child>`
24
+ }
25
+
14
26
const router = new VueRouter ( {
15
27
mode : 'history' ,
16
28
base : __dirname ,
17
29
routes : [
18
30
{ path : '/' , component : Hello } , // No props, no nothing
19
31
{ path : '/hello/:name' , component : Hello , props : true } , // Pass route.params to props
20
32
{ path : '/static' , component : Hello , props : { name : 'world' } } , // static values
21
- { path : '/dynamic/:years' , component : Hello , props : dynamicPropsFn } // custom logic for mapping between route and props
33
+ { path : '/dynamic/:years' , component : Hello , props : dynamicPropsFn } , // custom logic for mapping between route and props
34
+ { path : '/attrs' , component : Parent , props : { name : 'attrs' } }
22
35
]
23
36
} )
24
37
@@ -32,6 +45,7 @@ new Vue({
32
45
<li><router-link to="/hello/you">/hello/you</router-link></li>
33
46
<li><router-link to="/static">/static</router-link></li>
34
47
<li><router-link to="/dynamic/1">/dynamic/1</router-link></li>
48
+ <li><router-link to="/attrs">/attrs</router-link></li>
35
49
</ul>
36
50
<router-view class="view"></router-view>
37
51
</div>
0 commit comments