Like A Flowing Cloud

[Salesforce] Component 본문

Salesforce

[Salesforce] Component

Like A Flowing Cloud 2022. 10. 4. 10:44

1. Component 동작 원리 및 구조

Component  → Controller → Helper → Apex Controller

  • Component : 필수 요소로, 변수 선언 및 UI
  • Controller : JavaScript 구현 및 Component 의 Event 처리
  • Helper : 재사용 가능한 Function 구현 및 DML 처리
  • Apex Controller : CRUD

 

2. 변수 설정

<aura:attribute name="변수명" type="자료형" default=""/>

 

3.

{!c.} → controller 의 함수 호출 시 사용

{!v.} → attribute 사용 시 사용 

 

 

4. handler - init & change

  • init - 해당 컴포넌트를 처음 생성할 때 호출되는 initial 함수
  • name에 반드시 'init'과 'change'로 작성해야한다.

<aura:handler name="init" value="{!this}" action="{!c.fnInit}"/>
<aura:handler name="change" value="{!v.changeAttr}" action="{!c.fnChange}"/>

 

5. implements

implements="force:hasRecordId,force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes"

반드시 작성해야한다.

작성하지 않을 시, edit page 화면, Quick Action 컴포넌트 선택 창에 노출되지 않음.

+ 커뮤니티 화면일 경우 : forceCommunity:availableForAllPageTypes 추가