Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not explained how to catch CustomEvent #95

Open
vporton opened this issue Jan 21, 2021 · 2 comments
Open

It is not explained how to catch CustomEvent #95

vporton opened this issue Jan 21, 2021 · 2 comments

Comments

@vporton
Copy link

vporton commented Jan 21, 2021

It is not explained with an example how to catch CustomEvent in non-Vue code.

I tried several ways and none works. Please, give an example.

@vporton
Copy link
Author

vporton commented Jan 21, 2021

Maybe it worked in the past? It does not work with modern browsers (Chromium Version 87.0.4280.141 and Firefox 84.0.2), I tried whatever and it does not work: CustomEvent just does not fire.

@conanliuhuan
Copy link

In your components, u can use the following code to publish event:

this.$emit("eventName",eventData)

Outside the components, u can use the following code to catch event:

COMPONENT_ELEMENT.addEventListener("eventName",function(event){
    // console.log(event.detail)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants