기본 사용법

컴포넌트를 추가하고 속성, 상태, 이벤트를 애플리케이션에 연결합니다.

이벤트 연결#

일반 Button의 동작은 표준 click 이벤트로 처리합니다. 컴포넌트 프로퍼티나 메서드에 접근하기 전에는 등록이 완료될 때까지 기다립니다.

JavaScript
await customElements.whenDefined('sy-button');

const button = document.querySelector('#save-button');
button.addEventListener('click', async () => {
  button.loading = true;
  try {
    await saveChanges(); // 애플리케이션의 저장 함수
  } finally {
    button.loading = false;
  }
});

폼 제출은 폼의 submit 이벤트에서 처리하세요. Button이 제공하는 모든 속성과 메서드는 Button API에서 확인할 수 있습니다.