ExtJs 继承 extend

Ext.extend 对原生的prototype可以实现继承;

    var Base = function(){
    	this.dosomething = function(){
    		Ext.Msg.alert('info','doSomeThing');
    	}
    };
    
    Base.prototype.clear=function(){
    	Ext.Msg.alert('clear','Clear');
    }
    
    var child = function(){
    
    }
    
    Ext.extend(child,Base);
    
    
    var bodybar = new Ext.Toolbar({
    	items:[{text:'Login'},new Ext.Toolbar.Separator,{text:'Exit'},new Ext.Toolbar.Spacer,{text:'Quit',handler:function(){
    		Ext.getCmp('panel_id').setTitle('GetCMP');
    		var test = new child();
    		test.clear();                   //继承base.clear()
    		//test.clearsomething(); //不可以继承clearsomething
    	}}]
    });

猜你喜欢

转载自sants.iteye.com/blog/1711509