スーパーコンポーネントから継承される属性の設定
継承される属性の値を設定するには、サブコンポーネントのマークアップで <aura:set> を使用します。
例を見てみましょう。これは c:setTagSuper コンポーネントです。
1<!--c:setTagSuper-->
2<aura:component extensible="true">
3 <aura:attribute name="address1" type="String" />
4 setTagSuper address1: {!v.address1}<br/>
5</aura:component>c:setTagSuper の出力は、次のようになります。
1setTagSuper address1:address1 属性は設定されていないため、まだ値は出力されません。
これは c:setTagSuper を拡張する c:setTagSub コンポーネントです。
1<!--c:setTagSub-->
2<aura:component extends="c:setTagSuper">
3 <aura:set attribute="address1" value="808 State St" />
4</aura:component>c:setTagSub の出力は、次のようになります。
1setTagSuper address1: 808 State StsampleSetTagExc:setTagSub は、スーパーコンポーネント c:setTagSuper から継承される address1 属性の値を設定します。
使用コンポーネント内で参照することによってコンポーネントを使用している場合、マークアップでその属性値を直接設定できます。たとえば、c:setTagSuperRef は c:setTagSuper を参照し、aura:set を使用せずに address1 属性を直接設定します。
1<!--c:setTagSuperRef-->
2<aura:component>
3 <c:setTagSuper address1="1 Sesame St" />
4</aura:component>c:setTagSuperRef の出力は、次のようになります。
1setTagSuper address1: 1 Sesame St