@@ -14,6 +14,7 @@ export default {
14
14
value : PropTypes . any ,
15
15
name : String ,
16
16
id : String ,
17
+ autoFocus : Boolean ,
17
18
} ,
18
19
model : {
19
20
prop : 'checked' ,
@@ -33,6 +34,13 @@ export default {
33
34
: stateChecked ,
34
35
}
35
36
} ,
37
+ mounted ( ) {
38
+ this . $nextTick ( ( ) => {
39
+ if ( this . autoFocus ) {
40
+ this . $refs . input . focus ( )
41
+ }
42
+ } )
43
+ } ,
36
44
computed : {
37
45
classes ( ) {
38
46
const { prefixCls, disabled, stateChecked } = this
@@ -78,6 +86,24 @@ export default {
78
86
} )
79
87
}
80
88
} ,
89
+ focus ( ) {
90
+ this . $refs . input . focus ( )
91
+ } ,
92
+ blur ( ) {
93
+ this . $refs . input . blur ( )
94
+ } ,
95
+ onFocus ( e ) {
96
+ this . $emit ( 'focus' , e )
97
+ } ,
98
+ onBlur ( e ) {
99
+ this . $emit ( 'blur' , e )
100
+ } ,
101
+ onMouseEnter ( e ) {
102
+ this . $emit ( 'mouseenter' , e )
103
+ } ,
104
+ onMouseLeave ( e ) {
105
+ this . $emit ( 'mouseleave' , e )
106
+ } ,
81
107
} ,
82
108
watch : {
83
109
checked ( val ) {
@@ -88,13 +114,25 @@ export default {
88
114
} ,
89
115
} ,
90
116
render ( ) {
91
- const { id, classes, checkboxClass, disabled, prefixCls, stateChecked, handleChange, name, $slots } = this
117
+ const { id, classes, checkboxClass, disabled, prefixCls,
118
+ stateChecked, handleChange, name, $slots,
119
+ onFocus,
120
+ onBlur,
121
+ onMouseEnter,
122
+ onMouseLeave,
123
+ } = this
92
124
return (
93
- < label class = { classes } >
125
+ < label
126
+ class = { classes }
127
+ onMouseenter = { onMouseEnter }
128
+ onMouseleave = { onMouseLeave }
129
+ >
94
130
< span class = { checkboxClass } >
95
131
< input name = { name } type = 'radio' disabled = { disabled }
96
132
class = { `${ prefixCls } -input` } checked = { stateChecked }
97
- onChange = { handleChange } id = { id }
133
+ onChange = { handleChange } id = { id } ref = 'input'
134
+ onFocus = { onFocus }
135
+ onBlur = { onBlur }
98
136
/>
99
137
< span class = { `${ prefixCls } -inner` } />
100
138
</ span >
0 commit comments