File tree 2 files changed +16
-4
lines changed
packages/vue/example/componentsAttrs 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ export default {
16
16
h ( Child , {
17
17
// 这里会进行了统一的规范: name & age 如果是props 则会在组件内部通过defineProps进行定义 其余的属性统一当做attrs(即不属于props的都会被当成attrs)
18
18
name : 'coderwei' ,
19
- age : this . age ,
20
- number : 95527666 ,
19
+ age : 19 ,
20
+ number : this . age ,
21
21
cart : 'bar'
22
22
} ) ,
23
23
h ( 'button' , { onClick : this . handleClick } , 'add' )
Original file line number Diff line number Diff line change @@ -10,8 +10,20 @@ export default {
10
10
type : Number
11
11
}
12
12
} ,
13
- setup ( ) { } ,
13
+ setup ( props , ctx ) {
14
+ const handleClick = ( ) => {
15
+ console . log ( ctx . attrs . number )
16
+ }
17
+ return {
18
+ handleClick
19
+ }
20
+ } ,
14
21
render ( ) {
15
- return h ( 'div' , `age:${ this . age } ` )
22
+ return h (
23
+ 'div' ,
24
+ { } ,
25
+ h ( 'div' , `age:${ this . age } ` ) ,
26
+ h ( 'button' , { onClick : this . handleClick } , 'add3' )
27
+ )
16
28
}
17
29
}
You can’t perform that action at this time.
0 commit comments