fix: radio `focus` `blur` `autofocus` `mouseenter` `mouseleave` not working
parent
8dd123dbf9
commit
6a7dacf9a2
|
@ -14,6 +14,7 @@ export default {
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
name: String,
|
name: String,
|
||||||
id: String,
|
id: String,
|
||||||
|
autoFocus: Boolean,
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
prop: 'checked',
|
prop: 'checked',
|
||||||
|
@ -33,6 +34,13 @@ export default {
|
||||||
: stateChecked,
|
: stateChecked,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
if (this.autoFocus) {
|
||||||
|
this.$refs.input.focus()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
classes () {
|
classes () {
|
||||||
const { prefixCls, disabled, stateChecked } = this
|
const { prefixCls, disabled, stateChecked } = this
|
||||||
|
@ -78,6 +86,24 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
focus () {
|
||||||
|
this.$refs.input.focus()
|
||||||
|
},
|
||||||
|
blur () {
|
||||||
|
this.$refs.input.blur()
|
||||||
|
},
|
||||||
|
onFocus (e) {
|
||||||
|
this.$emit('focus', e)
|
||||||
|
},
|
||||||
|
onBlur (e) {
|
||||||
|
this.$emit('blur', e)
|
||||||
|
},
|
||||||
|
onMouseEnter (e) {
|
||||||
|
this.$emit('mouseenter', e)
|
||||||
|
},
|
||||||
|
onMouseLeave (e) {
|
||||||
|
this.$emit('mouseleave', e)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
checked (val) {
|
checked (val) {
|
||||||
|
@ -88,13 +114,25 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
render () {
|
render () {
|
||||||
const { id, classes, checkboxClass, disabled, prefixCls, stateChecked, handleChange, name, $slots } = this
|
const { id, classes, checkboxClass, disabled, prefixCls,
|
||||||
|
stateChecked, handleChange, name, $slots,
|
||||||
|
onFocus,
|
||||||
|
onBlur,
|
||||||
|
onMouseEnter,
|
||||||
|
onMouseLeave,
|
||||||
|
} = this
|
||||||
return (
|
return (
|
||||||
<label class={classes}>
|
<label
|
||||||
|
class={classes}
|
||||||
|
onMouseenter={onMouseEnter}
|
||||||
|
onMouseleave={onMouseLeave}
|
||||||
|
>
|
||||||
<span class={checkboxClass}>
|
<span class={checkboxClass}>
|
||||||
<input name={name} type='radio' disabled={disabled}
|
<input name={name} type='radio' disabled={disabled}
|
||||||
class={`${prefixCls}-input`} checked={stateChecked}
|
class={`${prefixCls}-input`} checked={stateChecked}
|
||||||
onChange={handleChange} id={id}
|
onChange={handleChange} id={id} ref='input'
|
||||||
|
onFocus={onFocus}
|
||||||
|
onBlur={onBlur}
|
||||||
/>
|
/>
|
||||||
<span class={`${prefixCls}-inner`} />
|
<span class={`${prefixCls}-inner`} />
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in New Issue