分析ext之Panel的实例化过程
首先我们来看下Panel的父类对象
Panel -> Container -> BoxComponent -> Component -> Observable
当我们实例化一个Panel的时候("new Ext.Panel({...})"),他首先执行的是构造函数constructor方法,但由于Panel并没有constructor方法,所以在extend的时候,已经默认使用了父类的构造方法,纵观Panel的父类对象,
发现只有Component和Observable有对应的构造方法,再仔细看看Component的构造方法,发现了一行代码:
extend : function(){ // inline overrides var io = function(o){ for(var m in o){ this[m] = o[m]; } }; var oc = Object.prototype.constructor; return function(sb, sp, overrides){ if(Ext.isObject(sp)){ overrides = sp; sp = sb; sb = overrides.constructor != oc ? overrides.constructor : function(){sp.apply(this, arguments);}; } var F = function(){}, sbp, spp = sp.prototype; F.prototype = spp; sbp = sb.prototype = new F(); sbp.constructor=sb; sb.superclass=spp; if(spp.constructor == oc){ spp.constructor=sp; } sb.override = function(o){ Ext.override(sb, o); }; sbp.superclass = sbp.supr = (function(){ return spp; }); sbp.override = io; Ext.override(sb, overrides); sb.extend = function(o){return Ext.extend(sb, o);}; return sb; }; }()