解释Ext的apply和override的区别

来源:互联网 发布:php关联添加元素 编辑:程序博客网 时间:2024/05/15 19:48

首先看源码:

  1. Ext.override function(origclass, overrides){  
  2.        if(overrides){  
  3.            var origclass.prototype;  
  4.            Ext.apply(p, overrides);  
  5.            if(Ext.isIE && overrides.toString != origclass.toString){  
  6.                  p.toString overrides.toString;  
  7.              
  8.         
  9. };  
  10.   
  11. Ext.apply function(o, c, defaults){  
  12.         if(defaults){  
  13.         Ext.apply(o, defaults);  
  14.      
  15.     if(o && && typeof == 'object'){  
  16.         for(var in c){  
  17.             o[p] c[p];  
  18.          
  19.      
  20.     return o;  
  21. };  

根据源码我们可以看到override是把对象overrides的方法和属性复制到对象origclass的prototype对象里,在某个程度上这两方法的功能是一样的 。

参考地址:http://www.iteye.com/topic/770292#1684417

原创粉丝点击