Search code examples
vue.jschildren

Display children inside component


My question is simple: How can I render the children of my component?

I have a template:

<template>
  <div id="app">
    <menubar color="#263238">
      <button>click</button>
    </menubar>
  </div>
</template>

and menubar is the component I created. How can I now render the button-tag inside the menubar component?


Solution

  • You should use slots for this. Please, check the link in the Vue docs: https://v2.vuejs.org/v2/guide/components-slots.html.

    enter image description here