父组件里用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>