VUEJS Listen lifecycle hook from the child component
florent giraud

florent giraud @flozero

Location:
Montreal
Joined:
Mar 12, 2019

VUEJS Listen lifecycle hook from the child component

Publish Date: Mar 18 '19
9 4

Here's a very useful tip I learnt from Vuedose.

In some cases I needed to know when a component has been created, mounted or updated from a parent component.

So you already tried something like this

    <Child @mounted="doSomething"/>.
Enter fullscreen mode Exit fullscreen mode

Let me tell you this: It will not work ˆˆ.

Instead, the solution is as simple as listening to an event with the lifecycle hook name, prefixed by @hook:.

    <Child @hook:mounted="childMounted"/>
Enter fullscreen mode Exit fullscreen mode

If you dont trust the tip check the yourself in this CodeSandbox

Thank's to Vuedose for this tip. Go check their website and sign to the newsletter 😄

Comments 4 total

Загрузка комментариев...
Add comment