Skip to content

add eventHandler after component mounted #2155

Closed
@IndexXuan

Description

@IndexXuan

What problem does this feature solve?

I am writing VCA called useEventListener,which can be used to addEventListener with native HTML element and $on with Vue Component(2.0 @vue/composition-api)。while in Vue 3.0, there are no $on any more and cannot add new eventHandler after component mounted(e.g. with component ref)

What does the proposed API look like?

<el-button @click="handleClick">click</el-button>,then we can use handleClick
but with
<el-button ref="buttonRef">click me</el-button>

useEventListener('click', evt => alert(1), false, buttonRef) // cannot get buttonRef.$on or set buttonRef.onClick(onXXX) in 3.0

readonly proxy can set onXXX instead of reject with warning message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions