ExtJs关于Ext.extend()的说明
来源:互联网 发布:linux directory 编辑:程序博客网 时间:2024/05/21 00:45
Ext.extend方法是用来实现类的继承。
extend(Object subclass,Object superclass,[Object overrides] : Object
第一个参数:子类
第二个参数:父类
第三个参数:要覆盖的属性。
这里需要强调一下,子类继承下来的是父类中通过superclass.prototype方式定义的属性(包括用此方法定义的函数)。
例子如下:
Js代码
- <script type="text/javas
cript" > - function S(){
- }
- S.prototype.s = "s";
- S.prototype.s1 = "s1";
- function C(){
- this.c = "c";
- this.c1 = "c1";
- }
- Ext.extend(C,S,{s1:"by c overload"});
- var c = new C();
- alert(c.s); //s
- alert(c.s1); //by c overload
- </script>
<script type="text/javascript"> function S(){ } S.prototype.s = "s"; S.prototype.s1 = "s1"; function C(){ this.c = "c"; this.c1 = "c1"; } Ext.extend(C,S,{s1:"by c overload"}); var c = new C(); alert(c.s); //s alert(c.s1); //by c overload </script>
如果按下面这个方式写就会提示c.s没有定义(undefind):
Js代码
- <script type="text/javas
cript" > - function S(){
- this.s = "s";
- this.s1 = "s1";
- }
- function C(){
- this.c = "c";
- this.c1 = "c1";
- }
- Ext.extend(C,S,{s1:"by c overload"});
- var c = new C();
- alert(c.s); //undefind
- alert(c.s1); //by c overload
- </script>
<script type="text/javascript"> function S(){ this.s = "s"; this.s1 = "s1"; } function C(){ this.c = "c"; this.c1 = "c1"; } Ext.extend(C,S,{s1:"by c overload"}); var c = new C(); alert(c.s); //undefind alert(c.s1); //by c overload </script>
也可以通过如下方式来实现类的继承
Js代码
- <script type="text/javas
cript" > - function S(){
- }
- S.prototype.s = "s";
- S.prototype.s1 = "s1";
- C = Ext.extend(S,{s1:"by c overload"});
- var c = new C();
- alert(c.s); //s
- alert(c.s1); //by c overload
- </script>
<script type="text/javascript"> function S(){ } S.prototype.s = "s"; S.prototype.s1 = "s1"; C = Ext.extend(S,{s1:"by c overload"}); var c = new C(); alert(c.s); //s alert(c.s1); //by c overload </script>
此时,C是子类,S是父类
"雪见"杨幂邀你共品3D国韵网游《天下贰》,海报免费领
- ExtJs关于Ext.extend()的说明
- ExtJs关于Ext.extend()的说明
- ExtJs关于Ext.extend()的说明
- ExtJs关于Ext.extend()的说明
- ExtJs关于Ext.extend()的说明
- Extjs- Ext.extend函数的使用
- Extjs- Ext.Extend函数的使用
- Extjs 研究 Ext.extend
- JavaScript和ExtJS的继承 Ext.extend Ext.applyIf
- ExtJS的extend(Ext Designer的使用)
- extjs的Ext.extend的使用样例(Ext继承)
- ExtJS学习------Ext.define的继承extend,用javascript实现类似Ext的继承
- Ext的extend继承
- Ext Js的extend
- 关于Ext.extend源码学习
- 关于Extjs--- Ext.onReady()的用法
- Ext的extend继承1
- Ext的extend继承1
- extjs 问题集锦 好贴 转
- ext总结 好帖 【转】
- extjs 问题集锦2 好帖 转
- 实现Ext Grid宽高自适应 实现loading image
- Ext中的get、getDom、getCmp、getBody、getDoc的区别
- ExtJs关于Ext.extend()的说明
- Ext.template分析
- 文件操作基础类
- extJs 2.0学习笔记(事件注册总结篇)
- 【win7系统怎样进去登陆界面】
- 引用 extJs 2.0学习笔记(事件注册总结篇)
- 体内湿气重怎样祛除
- EXTJS 学习
- gridpanel 第一次显示内容 第二次无法显示