FrontEnd/Ext
생성자 초기화
ejyoovV
2021. 10. 5. 20:33
ExtJS 'config'에 속성을 설정할 경우 해당 속성은 자동으로 get, set 접두어를 붙여서 메소드로 사용할 수 있다.
config:{
id:null
}
this.getId();
this.setName('값');
config 를 사용하여 class 를 정의할 때, 생성자를 통한 초기화를 진행할 수 있다.
* 생성자 문법
constructor:function(config){
this.initConfig(config);
}
* 코드 적용(앱에서 해당 파일 더블클릭하여 실행)
Ext.onReady : HTML 페이지가 출력된 후 수행
Ext.onReady(function(){
Ext.define('TestConstructor',{
config:{
id:null
},
constructor:function(config){
this.initConfig(config);
},
classFunction1:function(){
document.write(this.getId()+'classFunction1<br>');
},
classFunction2:function(){
document.write(this.getId()+'classFunction2<br>');
}
});
var id1 = Ext.create('TestConstructor',{
id:'id1'
});
id1.classFunction1();
id1.classFunction2();
}