Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Event handling in Vue.js

I have a situation where in an event is fired from parent component is being listen to by several child components.

e.g.
Parent Component: emit -> "orderReceived"
Child Component1( Tab1): on-> "orderReceived" -> fetch array1 from server
Child Component2( Tab2): on-> "orderReceived" -> fetch array2 from server

when both these tabs are opened, everything works fine. What I'm struggling with is, destroying event listeners on Tab1 and still be able to listen on Tab 2. ( when the tab1 is closed). Right now if the listeners of Tab1 are destroyed, it disables listeners on Tab 2 as well.

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The event must removed from component which was listening not both, You need to use $off, to just removed selected event, not all events from the specific component only, not to both

const ChildComponent1 = {
  methods:{
    orderReceived(){
      //orderReceived event emit
    }
  },
  created(){
    EventBus.$on('YOURCONTENT', this.orderReceived)
  },
  beforeDestroy(){
    EventBus.$off('YOURCONTENT', this.orderReceived)
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda