スーパーコンポーネントから継承される属性の設定
継承される属性の値を設定するには、サブコンポーネントのマークアップで <aura:set> を使用します。
例を見てみましょう。これは docsample:setTagSuper コンポーネントです。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSuper-->
18<aura:component extensible="true">
19 <aura:attribute name="address1" type="String" />
20 setTagSuper address1: {!v.address1}<br/>
21</aura:component>
22docsample:setTagSuper の出力は、次のようになります。
1setTagSuper address1:address1 属性は設定されていないため、まだ値は出力されません。
これは docsample:setTagSuper を拡張する docsample:setTagSub コンポーネントです。
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSub-->
18<aura:component extends="docsample:setTagSuper">
19 <aura:set attribute="address1" value="808 State St" />
20</aura:component>
21docsample:setTagSub の出力は、次のようになります。
1setTagSuper address1: 808 State StsampleSetTagExdocsample:setTagSub は、スーパーコンポーネント docsample:setTagSuper から継承される address1 属性の値を設定します。
使用コンポーネント内で参照することによってコンポーネントを使用している場合、マークアップでその属性値を直接設定できます。たとえば、docsample:setTagSuperRef は docsample:setTagSuper を参照し、aura:set を使用せずに address1 属性を直接設定します。
1swfobject.registerObject("clippy.codeblock-4", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17<!--docsample:setTagSuperRef-->
18<aura:component>
19 <docsample:setTagSuper address1="1 Sesame St" />
20</aura:component>
21docsample:setTagSuperRef の出力は、次のようになります。
1swfobject.registerObject("clippy.codeblock-5", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17setTagSuper address1: 1 Sesame St
18