core: [vue-compat] @click not working on components
Version
3.1.2
Reproduction link
https://github.com/liamdebeasi/vue3-repro
Steps to reproduce
- Clone repo and run
npm install. - Run
npm run serveto start up a dev server. - Click the “Click me!” text and observe that nothing is logged to your Dev Tools Console.
- Quit the dev server and comment out the
config.resolve.aliasline invue.config.jsto disable the compat mode. - Run the dev server again.
- Click the “Click me!” text and observe that this time the “Component was clicked!” text is logged to your Dev Tools Console.
What is expected?
I would expect that the click handler is fired regardless of whether or not I am using the compat build.
What is actually happening?
The click handler is only firing when not using the compat build.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (7 by maintainers)
.nativeis listed as being fully supported in compat build.@liamdebeasi Your app is missing is the second part of the webpack config described in the migration guide - setting the compiler to compat mode:
After I added this to your repro, click worked.
@inspire22
.nativeis fully supported by the migration build. If you found a scenario where it doesn’t work as intended, please open a new issue with a reproduction so we can check it out.@inspire22 The compiler config is not the solution in terms of Ionic.
Ionic exports Vue 3 components. But in compat mode, the app would treat them like Vue 2 components by default. You can do the following:
Which makes the alert pop up for me - without needing to add
.native.To make this less messy, you might have to come up with a clever wrapper or sth. Idea:
This will add a very small one-time runtime overhead, but should not be harmful considering Vue 3 itself is faster than Vue 2.