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

大家讲道理
大家讲道理

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

모든 응답(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

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿