javascript - vue的组件可以传children进去的吗?
大家讲道理
大家讲道理 2017-04-10 17:12:20
0
2
280
<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的时候才能静态获得子对象

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

Antworte allen(2)
刘奇

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

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage