[Vuejs]-Getting data from another component on created() VueJS

0👍

There a few way you can handle this

  1. You could emit an event at startup. In your case running bus.$emit("contentChange", "Delaware"); But you could have timing issues, if you fire the event, but the listening components aren’t initialised then you’ll miss it.
  2. A more robust method would be to use Vuex. You’ll set up your store and trigger a mutation at the start that sets the default location. After that any component can use the state to figure out what is the current selected location.

Leave a comment