LoginSignup
3
1

More than 5 years have passed since last update.

Lightning Web Components(標準Lightingコンポーネント)

Last updated at Posted at 2019-01-30

Lightning Web Components コンポーネントリファレンス

  • Auraコンポーネントと異なり コンポーネント名は - (ハイフン)で単語を繋げている
  • 閉じタグが必要
  • {}により変数をセットする場合は "(ダブルクォテーション)で囲む必要はない

アイコン

リファレンス
Screen Shot 2019-01-30 at 22.49.34.png

<lightning-icon icon-name="standard:user" size="small"></lightning-icon>ユーザー情報

テキスト表示

リファレンス

<lightning-formatted-text value={data.Name}></lightning-formatted-text>

データテーブル

リファレンス

Screen Shot 2019-01-30 at 22.48.56.png

<lightning-datatable
   key-field="id"
   data={records.data}
   columns={columns}
   onrowaction={rowAction}
   hide-checkbox-column="true"
   resize-column-disabled="true">
</lightning-datatable>
export default class lwc_sample extends NavigationMixin(LightningElement) {
    @track columns;           //カラムの定義

・・・

/*
 * 初期化処理
 */
connectedCallback() {
    this.setHeaderColumns();
}

/*
 * DataTableのカラム定義を設定する
 */
setHeaderColumns() {
    let actions = [
        { label: '詳細を見る', name: 'show_details' }
    ];

    this.columns = [
        { label: '商談名', fieldName: 'Name', type: 'text' },
        { label: '金額', fieldName: 'Amount', type: 'currency', cellAttributes: { alignment: 'left' } },
        { label: 'フェーズ', fieldName: 'StageName', type: 'text' },
        { type: 'action', typeAttributes: { rowActions: actions } }
    ];
}

/*
 * 行の右側のドロップダウンリストをクリック
 */
rowAction(evt) {
    evt.preventDefault();
    evt.stopPropagation();

    let action = evt.detail.action;
    let row = evt.detail.row;

    if (action.name === 'show_details') {
        this[NavigationMixin.Navigate]({
            type: "standard__recordPage",
            attributes: {
                recordId: row.Id,
                objectApiName: "Opportunity",
                actionName: "view"
            }
        });
    }
}

Spinner

リファレンス
Screen Shot 2019-01-30 at 22.44.32.png

<div style="position:relative">
  <div if:false={isLoaded}>
    <lightning-spinner variant="brand" size="medium"></lightning-spinner>

・・・

  </div>
</div>
export default class lwc_sample extends NavigationMixin(LightningElement) {
    @track isLoaded = false;  //ロード状態の識別フラグ

・・・

/*
 * 描画後に呼び出される
 */
renderedCallback() {
    this.isLoaded = true;
}

ボタン

リファレンス

Screen Shot 2019-01-30 at 22.59.16.png

<!-- 通常のボタン -->
<lightning-button
  variant="Neutral"
  label="ダウンロード"
  onclick={handleClick}
  class="slds-m-left_x-small">
</lightning-button>

<!--アイコン付きボタン -->
<lightning-button
  variant="Neutral"
  label="ダウンロード"
  icon-name="utility:download"
  icon-position="left"
  onclick={handleClick}
  class="slds-m-left_x-small">
</lightning-button>
/*
 * ボタンクリック
 */
handleClick(event) {
  //ボタンクリック時の処理
}
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1