日期:2014-05-16  浏览次数:20310 次

Extjs4 initComponent 和 constructor 的一点问题
Ext.define('DynamicButtonText', {
              extend: 'Ext.button.Button',
     
              initComponent: function() {
                  this.text = "ss";
                  alert("alert in initComponent second") 
                  this.renderTo = Ext.getBody();       
              },
              constructor:function(){
              	  this.text = new Date();
                  alert("alert in constructor first")
                  //如果initComponet,constructor同时存在callParent必须写在constructor中
                  	//否则initComponet中的内容不执行
                  this.callParent(); 
              },
              scope:this
          });
     
          Ext.onReady(function() {
              Ext.create('DynamicButtonText');
          });