Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to pass shared props in several child components in Vue?

In react I can declare some object…

const shared_props = {
  prop1: 'value1',
  prop2: 'value2',
  prop3: 'value3',
};

…and then pass it to several child components like this:

<ChildComponent1 {...shared_props} />
<ChildComponent2 {...shared_props} />
<ChildComponent3 {...shared_props} />

How can I do this in Vue?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Note that I’m not interesting in v-bind:shared_props="shared_props" because it’s not the same.

>Solution :

You can do it in this way :

<ChildComponent1 v-bind="shared_props" />

see more answers https://github.com/vuejs/vue/issues/4962

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading