[Vuejs]-Unable to retrieve data through eventBus in vuejs

0👍

Your mounted function is inside the computed section. As such it’ll be treated like a computed property and never invoked.

Try putting some console logging inside the mounted function. You should see that it is never called.

If you move the mounted function to be a top-level component option it should run fine.

As has already been noted in the comments you also don’t appear to be defining eventBus anywhere. I would have thought that you would be getting error messages in the console if this were the case. Perhaps you just omitted it from the question?

If not then this also suggests that the eventBus.$emit line is never being hit. I suggest adding yet more console logging to establish exactly what lines are and are not being run. It shouldn’t be difficult to narrow down the problem.

Leave a comment