initComponent 和constructor 的参数问题?
initComponent 可以取得constructor 中的参数吗?怎样取得? 2012-3-15
例证:
<script type="text/javascript">
//
Ext.define('Desktop',{
extend:'Ext.panel.Panel',
app:null,
initComponent:function(){
alert('app='+this.app); //注意此处 this.app 是 App 而不是null
}
});
//
Ext.define('App',{
constructor:function(){
var me=this;
desktopCfg=me.getDesktopConfig();
new Desktop(desktopCfg);
},
getDesktopConfig:function(){
var me=this,
cfg={
app:me
}
return cfg;
}
});
Ext.onReady(function(){
new App();
})
</script>
本文探讨了ExtJS框架中initComponent方法如何获取构造函数constructor传递的参数,并通过具体示例说明了这一过程。
1万+

被折叠的 条评论
为什么被折叠?



