Skip to content

vue3 + Web component doesn't emit basic custom event #5314

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

Closed
flozero opened this issue Jan 24, 2022 · 5 comments
Closed

vue3 + Web component doesn't emit basic custom event #5314

flozero opened this issue Jan 24, 2022 · 5 comments

Comments

@flozero
Copy link

flozero commented Jan 24, 2022

Version

3.2.29

Reproduction link

github.com

Steps to reproduce

  • npm i && npm run build
  • go to examples folder
  • go to vue2 or vue3 project
  • npm i && npm run serve
  • check that the click button doesnt send the event as it should

What is expected?

The event should be send.

What is actually happening?

doing nothing


I used defineEmits as define in the doc https://v3.vuejs.org/guide/web-components.html#definecustomelement nothing is working.

@LinusBorg
Copy link
Member

defineEmits works for for me when I do this:

const emit = defineEmits(['customme'])
const handleClick = () => {
  emit('customme', {
    test: 'information'
  })
}

Kapture 2022-01-24 at 08 36 31

@flozero
Copy link
Author

flozero commented Jan 24, 2022

Definitely working thank you ! What would be the best practice with a vue2 project . Ref to #5313

@flozero
Copy link
Author

flozero commented Jan 24, 2022

Also the event are not working in the react project. Is it a limitation from react ?

@LinusBorg
Copy link
Member

Yes, I think so. React uses its own synthetic event system which, as far as I understand, doesn't work seamlessly with CustomEvents

@LinusBorg
Copy link
Member

Please take further questions back to discord.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants