MyPanel = function(config){ //用户配置 var config = config || {}; //默认配置 var defaultConfig = { title:"默认面板", width:300, height:500, buttons:[ {text:"按钮1"} ] }; //将defaultConfig的属性复制到config,若属性已存在,则不复制 Ext.applyIf(config,defaultConfig); //调用父类构造函数 MyPanel.superclass.constructor.call(this,config); } //实现继承 Ext.extend(MyPanel,Ext.Panel);
Ext.onReady(function(){ var a =new MyPanel({renderTo:"hello"}); });