diff --git a/components/radio/Radio.jsx b/components/radio/Radio.jsx index 5ba13dd2c..1108412cd 100644 --- a/components/radio/Radio.jsx +++ b/components/radio/Radio.jsx @@ -14,6 +14,7 @@ export default { value: PropTypes.any, name: String, id: String, + autoFocus: Boolean, }, model: { prop: 'checked', @@ -33,6 +34,13 @@ export default { : stateChecked, } }, + mounted () { + this.$nextTick(() => { + if (this.autoFocus) { + this.$refs.input.focus() + } + }) + }, computed: { classes () { 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: { checked (val) { @@ -88,13 +114,25 @@ export default { }, }, 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 ( -