fix: add radioGroup mouse event & radio name inherit radioGroup name

pull/77/merge
tjz 7 years ago
parent f7886c7203
commit 90634d19b3

@ -63,6 +63,12 @@ export default {
this.$emit('input', targetValue) this.$emit('input', targetValue)
this.$emit('change', event) this.$emit('change', event)
}, },
onMouseEnter (e) {
this.$emit('mouseenter', e)
},
onMouseLeave (e) {
this.$emit('mouseleave', e)
},
}, },
watch: { watch: {
value (val) { value (val) {
@ -70,9 +76,16 @@ export default {
}, },
}, },
render () { render () {
const { radioOptions, classes, $slots, name } = this const { radioOptions, classes, $slots, name,
onMouseEnter,
onMouseLeave,
} = this
return ( return (
<div class={classes}> <div
class={classes}
onMouseenter={onMouseEnter}
onMouseleave={onMouseLeave}
>
{radioOptions.map(({ value, disabled, label }) => {radioOptions.map(({ value, disabled, label }) =>
<Radio key={value} value={value} disabled={disabled} name={name}>{label}</Radio>)} <Radio key={value} value={value} disabled={disabled} name={name}>{label}</Radio>)}
{ radioOptions.length === 0 && ($slots.default || []).filter(c => c.tag || c.text.trim() !== '')} { radioOptions.length === 0 && ($slots.default || []).filter(c => c.tag || c.text.trim() !== '')}

@ -114,13 +114,19 @@ export default {
}, },
}, },
render () { render () {
const { id, classes, checkboxClass, disabled, prefixCls, const { id, classes, checkboxClass, prefixCls,
stateChecked, handleChange, name, $slots, stateChecked, handleChange, $slots,
onFocus, onFocus,
onBlur, onBlur,
onMouseEnter, onMouseEnter,
onMouseLeave, onMouseLeave,
radioGroupContext,
} = this } = this
let { name, disabled } = this
if (radioGroupContext) {
name = radioGroupContext.name
disabled = disabled || radioGroupContext.disabled
}
return ( return (
<label <label
class={classes} class={classes}

Loading…
Cancel
Save