首页 > vue的组件可以传children进去的吗?

vue的组件可以传children进去的吗?

<my-component>something</my-component>
<!--怎么在my-component里获得something ??-->
<parent-component>
    <my-component>
        <child1></child1> <!--怎么在my-component里获得child1 ??-->
    </my-component>
    <my-component>
        <child2></child2> <!--怎么在my-component里获得child2 ??-->
    </my-component>
<parent-component>

在React里是通过this.props.children获得

通过v-ref只能在定义template的时候才能静态获得子对象


http://vuejs.org/guide/components.html#Child_Component_Refs


解决这个问题使用的是Solt
http://vuejs.org/guide/components.html#Content_Distribution_with_Slots
http://cn.vuejs.org/guide/components.html#u4F7F_u7528_Slot__u5206_u53D1_u5185_u5BB9

【热门文章】
【热门文章】