Extjs- Ext.extend函数的使用

简介: Ext.extend在Extjs 中扮演着重大角色,是Extjs中几个重要函数之一。要想深入了解EXTJS,这个函数必须掌握不可,网上有很多关于这个函数的源码分析和介绍。关于这个函数的使用有以下几种情况。

 Ext.extend在Extjs 中扮演着重大角色,是Extjs中几个重要函数之一。要想深入了解EXTJS,这个函数必须掌握不可,网上有很多关于这个函数的源码分析和介绍。关于这个函数的使用有以下几种情况。

function Base(config) {   this.name=config.name;   this.age=config.age;   this.sex=config.sex; }  function base(config) {  this.identity=config.identity;  this.msg=config.msg;  this.phone=config.phone;    base.superclass.constructor.call(this,config); }  Ext.extend(base,Base,{    showMsg:function(){      window.alert(this.name+' '+this.age+' '+this.sex+' '+this.identity+' '+this.msg+' '+this.phone);    } });

在这种情况下
  1.  1
 

     第二种情况是

function Base(config) {  this.name=config.name;  this.age=config.age;  this.sex=config.sex;  } 
var base=Ext.extend(Base,{    showMsg:function(){      window.alert(this.name+' '+this.age+' '+this.sex+' '+this.identity+' '+this.msg+''+this.phone);    } }
var mybase=new base( /* */); 将会调用Base constructor函数
 
第三种情况
function Base(config) {  this.name=config.name;  this.age=config.age;  this.sex=config.sex;  } 
var base=Ext.extend({ constructor:function(config){    this.identity=config.identity;    this.msg=config.msg;   this.phone=config.phone; }, showMsg:function(){     window.alert(this.name+' '+this.age+' '+this.sex+' '+this.identity+' '+this.msg+''+this.phone);   } }
mockup_2
此时  var mybase= new base(  /* */);  将会调用Ext.extend中传入的constructor函数
 
     对Ext.extend使用的三种情况全部分析完了,Extjs中的继承体系都是采用以上三种情况构建成。文章中的文字描述很少。如果你看完些文,不知所解,可以先对Ext.extend函数源码进行分析,在自己多调试几次,再回过头来看,估计一下子就会明白文章意思。画图是使用balsamiq软件。
目录
相关文章
|
JavaScript
jQuery $.extend()用法总结
jQuery $.extend()用法总结   1.合并多个对象 var Css1={size: "10px",style: "oblique"} var Css2={size: "12px",style: "oblique",weight: "bolder"} $.
953 0
|
Web App开发 前端开发 JavaScript
《Ext JS实战》——2.2 Ext.Element类
这个getElementById方法很好用,可以执行一些类似改变innerHTML的内容,或者美化和配置一个CSS类这样的基本任务。不过要是想对该节点做更多的事情,例如管理它的事件,在有鼠标点击时应用某个样式,或者替换一个CSS类?必须自己管理全部代码,还要不断地对代码进行更新,以保证能够全部浏览器的兼容性。
1705 0
|
JavaScript
4.Ext JS Ext.data.Store本地过滤
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/inforstack/article/details/53608732 var myStore = Ext.
834 0
|
前端开发 JavaScript .NET
|
JavaScript 前端开发
|
JavaScript 前端开发