extend

 /////////////////////SubClass,SuperClass,

 

Ext.extend(baseClass, SubClass, Overrides) ,

 

 

 ////////////////return Developer.superclass.getName.call(this);   

  1. // 基类Persion,继承自Object  
  2. Person = Ext.extend(Object, {  
  3.     constructor: function(first, last){  
  4.         this.firstName = first;  
  5.         this.lastName = last;  
  6.     },  
  7.  
  8.     getName: function(){  
  9.         return this.firstName + ' ' + this.lastName;  
  10.     }  
  11. });  
  12. // 继承Person得到Developer的子类  
  13. Developer = Ext.extend(Person, {  
  14.     getName: function(){  // 重写了getName()方法  
  15.         if(this.isCoding){  
  16.             return 'Go Away!';  
  17.         }else{  
  18.             // 访问父类的方法  
  19.             return Developer.superclass.getName.call(this);   
  20.         }  
  21.     }  
  22. });  
  23. // 测试是否成功继承  
  24. var p = new Person('John', 'Smith');  
  25. alert("Hi," + p.getName() + "欢迎来到学习Ext的殿堂:)"); 

你可能感兴趣的:(ext,Go)