Web Component Event Dispatching 하기
Web 2021. 8. 15. 15:44

앞서 만든 Web Component로 부터 이벤트에 따른 변화를 알아야 한다면 어떻게 해야 할까? 가련 버튼을 클릭한 이벤트의 횟수를 외부에서 알아야 한다면? 두가지 방법이 있다. get 을 이용해서 public value를 알아 내는 방법 get timesClicked(){ return this.timesClicked; } 또 하나는 Event를 통해서 업데이트 된 Data를 알아내는 방법이다. 여기서 두번째 방법에 대해서 알아보고자 한다. Event Button component 설계 html tag에서 onchange라고 하는 event를 등록하면 event를 수신받을 수 있도록 만들어 준다. Event Button component 개발 export default class EventButton ..