-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Vue compat] @click not working on a component #4566
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
Comments
You need to use the |
Oh, but in the documents, it says to remove all .natives? confused |
Also even with the .native modifier, it still doesnt work with the compat build of vue 3. https://codesandbox.io/s/sharp-proskuriakova-woc9s?file=/src/App.vue |
Are you using the migration build? The compiler flag you mentioned can only work with the migration build. See https://v3.vuejs.org/guide/migration/migration-build.html#migration-build |
Yes, as my title says, im using the vue 3 compat build which is the migration build. |
Could you reopen the issue please as this seems like a bug. I've been stuck with this issue all day :( |
So I've been looking into this, and it doesn't really qualify as a bug. Rather, it's a complicated interaction between multiple breaking changes and their corresponding COMPAT flags/behaviors. This might need a special entry in the migration docs. Short summary
SolutionIn the child component, the following export default {
compatConfig: {
INSTANCE_LISTENERS: false,
}
} This has the following effects:
If the child is already fully migrated and can run in Vue 3 mode, the problem would also be solved:
Concerning Migration documentationSo this is one of the most complex migration steps in fact, as it involves a change in behavior in the parent and child interaction.
So what would be a good migration strategy that we can document? I think this would be good
/cc @vuejs/docs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I fixed my issue by adding INSTANCE_LISTENERS: false as suggested 😀 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thank you @LinusBorg! I have been trying to figure out why this wasn't working. The only thing I will add to the above solution is some more details around where to put |
But it already says it has to be set "in the child component". And on top, the migration guide explains that all Compat flags that need to be set in the compiler Options are prefixed with COMPILER_* I'm not sure how to make it more clear, do you have a concrete suggestion? |
Yes, however, it is not explicit that only the flags that are prefixed with
On the Compat Configuration section, it defines 4 different places you add these flags. It doesn't offer any real explanation as to the purpose behind which one should be used, why and when it would make sense to use one over the other (as in this issue's case). Instead, the guide comes across as "provide these flags where ever you want". So, when I follow the installation in the guide for Which is what I did and why I couldn't get it to work prior to finding this issue. That is what I meant by "adding more details around where to put Adding a simple and general disclaimer on the guide that there might be times where you may need to add these flags specifically to components to get them to work properly. |
Thanks, that's something to work with 👍 |
@LinusBorg Stupid question, but if I have a project where I set compatConfig globally to Mode: 2 and then import a vanilla vue 3 component library (external npm dependency), does this force those components to run in Mode: 2 if they don't specifically declare a compatConfig with Mode: 3 themselves? |
Yes. So to leave them in Vue 3 more you would have to add that config to those components. Can be done at runtime. |
Thanks. Like this? If so, I think this behaviour and workaround should be documented, will try to open a PR with the docs project.
Background to my question: BootstrapVue, which is a fairly prevalent and widely used Vue library, requires setting I would have assumed that Vue somehow would prevent the described behavior when encountering external components written in Vue 3.0 - what does it even mean to force a component written with the composition API to conform to MODE: 2? |
Thanks for the clear explanations Linus. We had the issue while migrating to ElementPlus through the compat build, and we fixed it like this: // main.ts
import { ElForm } from 'element-plus';
ElForm.compatConfig = {
...ElForm.compatConfig,
INSTANCE_LISTENERS: false,
}; Then we can still prevent unwanted form submissions this way: <el-form @submit.prevent.stop="handleSubmit" /> |
As described in this GitHub issue comments: vuejs/core#4566 (comment) and suggested as a useful addition to the docs.
It's a complex issue with @vue/compat, see vuejs/core#4566 (comment)
Version
3.2.11
Reproduction link
codesandbox.io
Steps to reproduce
Clicking on "click mee"
What is expected?
Should log "click" in the console
What is actually happening?
Not doing anything
I tried adding
COMPILER_V_ON_NATIVE: false
to vue.config.js but it seems to make no difference. This issue only happens in the compat build of vueThe text was updated successfully, but these errors were encountered: