Subscribe on changes!

vue3 + Web component doesn't emit basic custom event

avatar
Jan 24th 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.

avatar
Jan 24th 2022

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

avatar
Jan 24th 2022

Definitely working thank you ! What would be the best practice with a vue2 project . Ref to https://github.com/vuejs/core/issues/5313

avatar
Jan 24th 2022

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

avatar
Jan 24th 2022

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

avatar
Jan 24th 2022

Please take further questions back to discord.