[Vuejs]-Call grandchild function from a child – vue.js

0πŸ‘

βœ…

In my opinion, you can’t right now directly call a child function of a brother. So, with your code, you can’t directly call a function of a component A, from a component B which is the brother of the A one.

But, you can do that with the grandparent component.
So, when the ManagmentArtifact.vue component need to call refreshArtifact function, you can emit an event. The TeamManagment.vue listen that event, and then pass use ref of TeamPlatform.vue component to call the function.

ManagmentArtifact.vue: this.$emit('callRefresh')
TeamManagment.vue: <ManagmentArtifact @callRefresh='refreshArtifact' />
<TeamPlatform ref='team' />
methods: { refreshArtifact(){ this.$ref.team.refreshArtifact() } }

You can read the doc here.

Leave a comment