Event handling / component communication

maluio
0
maluio
commented 2 months ago

What problem does this feature solve?

My use case was:
A button in a parent component triggers a method call in a child component.

I couldn't find a solution in the nuxtjs docs. Eventually, I stumbled upon this thread:
https://github.com/nuxt/nuxt.js/issues/849

Using

this.$root.$emit
this.$root.$on

solved my problem.

What does the proposed changes look like?

Ideally, a new page explains the available options for component communication: (this.$root.$emit, eventBus, …)

The new page could be available at https://nuxtjs.org/api/component-communiction

If this is a valid feature request I could write that page.

Thank you.

idea
0
manniL
4.9k
manniL
commented 2 months ago

Strongly personal suggestion: We have Vuex for state management. I highly recommend to avoid something an event bus.

A button in a parent component triggers a method call in a child component.
You can then pass down the event from the parent component ☺️

As this topic is more related to Vue (https://vuejs.org/v2/guide/events.html#ad) I'll close here.
Thanks anyway for the idea 👍

0
Informations
Feature RequestOpen
#c178 - Created 2 months ago