コンポーネントに属性を追加してみよう
コンポーネントに属性を追加します。
コンポーネントの属性はApexクラスのメンバー属性に似ています。
画面イメージ
![](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F86505%2F9e706e74-bb90-926a-91e7-640c0082c38b.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=4884c42e214c78c706106b5c726040a1)
ソース
m02_ComponentAttribute.cmp
<aura:component implements="force:appHostable">
<aura:attribute name="target" type="String" default="world"/>
<h1>Hello, {!v.target}!</h1>
</aura:component>
ポイント
<aura:attribute>
タグ
コンポーネントの属性です。
{!v.<属性名>}
でコンポーネントから属性にアクセスできます。
値プロバイダ
- v コンポーネントの属性セット
- c 固有のアクションおよびイベントハンドラを含むコンポーネントのコントローラ
補足
- P69 式
- P245 サポートされる aura:attribute の型
- P246 基本の型
- P72 値プロバイダ