fix: el-input add mouseenter mouseleave event (#349)

This commit is contained in:
zazzaz 2020-09-25 16:02:28 +08:00 committed by GitHub
parent 4263299c74
commit a5611000da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,8 +15,8 @@
$attrs.class
]"
:style="$attrs.style"
@mouseenter="hovering = true"
@mouseleave="hovering = false"
@mouseenter="onMouseEnter"
@mouseleave="onMouseLeave"
>
<template v-if="type !== 'textarea'">
<!-- 前置元素 -->
@ -222,7 +222,8 @@ export default defineComponent({
},
},
emits: [UPDATE_MODEL_EVENT, 'input', 'change', 'focus', 'blur', 'clear'],
emits: [UPDATE_MODEL_EVENT, 'input', 'change', 'focus', 'blur', 'clear',
'mouseleave', 'mouseenter'],
setup(props, ctx) {
const instance = getCurrentInstance()
@ -448,6 +449,16 @@ export default defineComponent({
nextTick(updateIconOffset)
})
const onMouseLeave = e => {
hovering.value = false
ctx.emit('mouseleave', e)
}
const onMouseEnter = e => {
hovering.value = true
ctx.emit('mouseenter', e)
}
return {
input,
textarea,
@ -478,6 +489,8 @@ export default defineComponent({
focus,
blur,
getSuffixVisible,
onMouseLeave,
onMouseEnter,
}
},
})