0

I want to passing the data to another component by using the eventbus. In main.js, I set the event bus and everything works properly, except for the code below. when I emit the data COMPONENT 1 (component which emit data)

emitovanje () {
    EventBus.$emit("UnverifiedCars", this.numberOfunverifiedCars)
}

and now in the second component I do

COMPONENT 2 (component which recieve data)

 created () {
            EventBus.$on("UnverifiedCars", numberOfunverifiedCars => {
              console.log(numberOfunverifiedCars)
   //this code return me data in Component 1

            })
        }
Sphinx
  • 10,519
  • 2
  • 27
  • 45
  • I want only numberOfunverifiedCars from component 1 to component 2. numberOfunverifiedCars is only one number which I want print in Component 2.This is communicate between adjacent components. I can use Vuex but I spent too much time on this and I want to finish it with the eventbus – AleksandarMihailovic Sep 20 '18 at 22:51
  • how you get variable=`EventBus` inside both component? by `import`? if so, show us that file which you import. or you inject your event bus instance to Vue root instance? – Sphinx Sep 20 '18 at 22:56
  • I main.js export const EventBus = new Vue(); in component import { EventBus } from './main.js'; That is no problem. Problem is on code above and EventBus.. Child to child compoonent.. – AleksandarMihailovic Sep 21 '18 at 07:53

0 Answers0