loadComponent API를 이용하여 컴포넌트 작성하기 2
유형별로 컴포넌트 파일을 작성하는 방법을 정리해 보았습니다.
case 1. Module type이 아닌 JS 파일경우
컴포넌트 정의 파일
// case 1. CompScript.js 파일 작성
(function(component){
// 컴포넌트 객체 정의
function Comp($self, config, onInitialize){
// 컴포넌트 기능 구현...
}
// Export
if(!component.Comp) component.Comp= Comp;
window['jikjiComponent'] = component;
})(window['jikjiComponent'] || {});컴포넌트 로드 방법
case 2. Module type인 경우 (type='module')
컴포넌트 정의 파일
컴포넌트 로드 방법 1
컴포넌트 로드 방법 2
다음 방법은 일반적이지 않아 권장하지는 않지만 사용 가능한 코드입니다.
initialize 이벤트에 코드 등록합니다.
Last updated