SFDC AURA Component 继承

父组件里用extensible='true'来声明可以继承

子组件用extends="c:super"来继承,Component里的属性,Controller,Helper都可以继承,但是建议在helper里实现继承方法不要在Controller里乱弄。

<!--c:super-->
<aura:component extensible="true">
    <aura:attribute name="description" type="String" default="Default description" />

    <p>super.cmp description: {!v.description}</p>

    {!v.body}
</aura:component>

子组件(子组件里要是想要重写属性,用Set方法即可)

<!--c:sub-->

<aura:component extends="c:super">

<p>sub.cmp description: {!v.description}</p>

</aura:component

容器组件

<!--c:containerBody-->
<aura:component>
    <c:subBody>
        Body value
    </c:subBody>
</aura:component>

抽象组件:abstract="true"

接口组件:用他来声明<aura:interface> ,里边儿只能放<aura:attribute>,在实现组件里用<aura:registerEvent>来注册事件,接口组件里用<aura:method>来声明方法(没有实现)。

例子:

        实现接口:<aura:component implements="mynamespace:myinterface" >

        实现接口并继承类:<aura:component extends="ns1:cmp1" implements="ns2:intf1" >

        实现多个接口:<aura:interface extends="ns:intf1,ns:int2" >

接口例子:

<aura:interface>
    <aura:attribute name="value" type="String"/>

    <aura:registerEvent name="onItemSelected" type="ui:response"
      description="The event fired when the user selects an item" />

    <aura:method name="methodFromInterface">
        <aura:attribute name="stringAttribute" type="String" default="default string"/>
    </aura:method>
</aura:interface>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值