Serio
Serio

Reputation: 527

Is there a way to pass elements to a vue component?

when I need to pass some information between child and parent element I use props. But is there a way to pass elements to the component, for example like this

<MyComponent>
 <router-link to="/oneOfTheList">OneOfTheList</router-link>
</MyComponent>

Router-Link seems to do it somehow... How can I specify where the elements will be placed in my component

Upvotes: 1

Views: 79

Answers (1)

gguney
gguney

Reputation: 2653

This is called slot

ComponentA.vue

<div>
  <slot></slot>
</div>

ComponentB.vue

<component-a>
    <span>test</span> // this part will be shown inside component A's slot tags
</component-a>

Here you go

Upvotes: 3

Related Questions