首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Ext学习之1_种的继承2

2012-11-03 
Ext学习之1_类的继承2Ext.namespace(com.deng)//Ext的继承更加优雅com.deng.Second function(){//???

Ext学习之1_类的继承2

Ext.namespace("com.deng");
//Ext的继承更加优雅
com.deng.Second = function(){
//??? com.deng.Second.superclass.constructor.apply(this);//调用父类构造方法
}

//用Ext.extend()实现继承: com.deng.Second 继承 com.deng.First
Ext.extend(com.deng.Second, com.deng.First,{
??? //为子类添加新的方法
??? fun: function(i){
??? ??? return i * i * i;
??? },
??? //重写方法
??? method: function(){
??? ??? alert("overrid First method");
??? }
});



Ext.onReady(function(){
??? //测试
??? var second = new com.deng.Second();
??? alert(second.fun(5));
??? second.method();
??? //不能调用的到first的init方法,只能调用到prototype定义的方法
});

热点排行