Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reacts this.props.children in vue.js component

React has something like this.props.children: https://facebook.github.io/react/tips/children-props-type.html

Does Vue.js have also some similar to access the child-elements?

like image 327
tiefenb Avatar asked Aug 16 '16 08:08

tiefenb


1 Answers

The equivalent to this.props.children in Vue is <slot />.

Example

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

See http://vuejs.org/guide/components.html#Content-Distribution-with-Slots

like image 193
Timo Ernst Avatar answered Sep 27 '22 16:09

Timo Ernst