Static GitHub Issues

[2025] Problem in listening to an event inside v-if block.

prev: Velocity.js doesn't work as ssr: false plugin, how to use it?
next: How to support gzip when nuxt generate?

I have a 3 level child to parent component communication, like bellow:

parent (this is inside page folder)
- child-1 (this is inside component folder)
-- child-2 (this is inside component folder)

So, when child-2 emits an event, child-1 receive and reemit the event to parent. It works well if i emit the event in child-2 in a synchronous way, but when i emit it in a asynchronous way, the child-1 do not get the event emitted by child-2, and of course, do not pass this event to parent.

But after i tried a lot, i notice that the problem only occurs because i'm using an v-if block, cause if the same code is not inside this v-if block, the flow goes well, even in asynchronous way. So i think thats nuxt is not setup the DOM relations correctly when v-if is used and the event is emitted inside an asynchronous method. Yeah, the error is specific like that, cause if the method is not asynchronous, works, and if i use v-show instead v-if, it works too. The only way to reproduce this error is using a 3 level communication component, and the first component to emit the event need to do this inside an asynchronous method, and the component that will directly listening to this event need to be inside an v-if block.

Ps: i'm using v-show for now, cause it is working in my case, but i thought that is important to open this issue and help the community to understand this kind of error and the possible solutions.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1799">#c1799</a>)</em></sub></div>