0

I have a layout file in which I have some data. Besides that I have three components:

  • tags
  • students
  • actions

I want to declare the data in the layout file, but access it through the three child-components.

How is this done in Vue.js?

Thank you for your help.

Timo
  • 261
  • 5
  • 18

1 Answers1

1

One option can be to pass the props to all the child components which is the norm in vue when it comes to passing data to child component, as also explained here.

Given that you want to pass same data to all these components and there can be cases going forward when you want to change this data and get it reflected in parent as well, you can go for a centralised state management, which is explained here in more detail.

tony19
  • 125,647
  • 18
  • 229
  • 307
Saurabh
  • 71,488
  • 40
  • 181
  • 244
  • ok, so I should go with VUEX ? I'm familiar with the concept of state, but have no clue what **actions** look like! – Timo Jan 25 '17 at 16:53
  • Yes, Vuex is in general recommended and popular in [community](http://stackoverflow.com/a/40924113/1610034), you can get more details from the [docs](https://vuex.vuejs.org/en/state.html). – Saurabh Jan 25 '17 at 18:01