/////////////////////SubClass,SuperClass,
Ext.extend(baseClass, SubClass, Overrides) ,
////////////////return Developer.superclass.getName.call(this);
- // 基类Persion,继承自Object
- Person = Ext.extend(Object, {
- constructor: function(first, last){
- this.firstName = first;
- this.lastName = last;
- },
- getName: function(){
- return this.firstName + ' ' + this.lastName;
- }
- });
- // 继承Person得到Developer的子类
- Developer = Ext.extend(Person, {
- getName: function(){ // 重写了getName()方法
- if(this.isCoding){
- return 'Go Away!';
- }else{
- // 访问父类的方法
- return Developer.superclass.getName.call(this);
- }
- }
- });
- // 测试是否成功继承
- var p = new Person('John', 'Smith');
- alert("Hi," + p.getName() + "欢迎来到学习Ext的殿堂:)");