List some types of components communication channels in Vue.js app

Technology CommunityCategory: Vue.jsList some types of components communication channels in Vue.js app
VietMX Staff asked 3 years ago
  • Props (props) – The simplest communication channel in Vue for direct Parent-Child communication. It should mostly be used to pass data relating to presentation logic or a restricted set of data down the hierarchy.
  • Refs and methods (ref) – When it doesn’t make sense to use a prop to let a child handle an event from a parent, setting up a ref on the child component and calling its methods is just fine.
  • Events ($emit and $on) – The simplest communication channel for direct Child-Parent communication. Again, should be used for presentation logic.
  • Event bus (this.$root.$emitthis.$root.$on) – This can become useful when passing props all over the place from far up down to deeply nested children components, with almost no other components needing these in between.
  • Centralized store (Vuex) – Vuex is the way to go with Vue for state management. It offers a lot more than just events and it’s ready for full scale application.