Ext类继承

来源:互联网 发布:昆明行知中学地址 编辑:程序博客网 时间:2024/05/22 14:35
 
var Person = Ext.emptyFn;  Ext.apply(Person.prototype,{   id:0,   name:"",   print:function(){    alert(String.format("id={0},name={1}",this.id,this.name));   }  });    /************************** 继承。******************/  var Student = function(cfg) {   Ext.apply(this,cfg);  }    // 类Student继承Person,并增加了一个字段address  Ext.extend(Student,Person,{   address:""  });    var student = new Student();  student.id = 2000;  student.name = "extends";  student.address =  "深圳市";  student.print();  alert(student.address);    student = new Student({id:3000,name:"china",address:"hub"});  student.print(); 

原创粉丝点击