zoukankan      html  css  js  c++  java
  • Ext中 get、getDom、getCmp的区别

    getDom方法能够得到文档中的DOM节点,该方法中包含一个参数,该参数可以是DOM节点的id、DOM节点对象或DOM节点对应的Ext元素(Element)等。 (与getElementById是一个效果)
    Ext.onReady(function(){  
      
    var e=new Ext.Element("hello");  
      
    Ext.getDom("hello");  
      
    Ext.getDom(e);  
      
    Ext.getDom(e.dom);  
      
    });  
    //Html页面中包含一个id为hello的div,代码如下:  
      
    <div id="hello">aaa</div> 
    在上面的代码中,Ext.getDom("hello")、Ext.getDom(e)、Ext.getDom(e.dom)等三个语句返回都是同一个DOM节点对象。
     
    get方法中只有一个参数,这个参数是混合参数,可以是DOM节点的id、也可以是一个Element、或者是一个DOM节点对象等。
    get方法其实是Ext.Element.get的简写形式。 
    Ext.onReady(function(){  
      
      var e=new Ext.Element("hello");  
      
      Ext.get("hello"));  
      
      Ext.get(document.getElementById("hello"));  
      
      Ext.get(e);  
      
    }); 
    //Html页面中包含一个id为hello的div,代码如下:  
      
    <div id="hello">aaa</div> 
    Ext.get("hello")、Ext.get(document.getElementById("hello"))、Ext.get(e)等三个方法都可以得到一个与DOM节点hello对应的Ext元素。
     
    getCmp方法用来获得一个Ext组件,也就是一个已经在页面中初始化了的Component或其子类的对象,getCmp方法中只有一个参数,也就是组件的id。
    getCmp方法其实是Ext.ComponentMgr.get方法的简写形式。
    Ext.onReady(function(){    
       var myPanel=new Ext.Panel({  
       id:“myFirstPanel”,  
       title:“旧的标题",    
       renderTo:"hello",
       300,   
       height:200 
    });  
      
    Ext.getCmp(" myFirstPanel ").setTitle("新的标题");  
      
    });    
    //Html页面中包含一个id为hello的div,代码如下:  
      
    <div id="hello">aaa</div> 
    我们使用Ext.getCmp(“myFirstPanel").来得到id为myFirstPanel的组件,并调用其setTitle方法来设置该面板的标题 
  • 相关阅读:
    QML小例子【QML工程里信号与槽】
    TensorFlow基础笔记(11) conv2D函数
    tensorflow学习笔记(10) mnist格式数据转换为TFrecords
    tensorflow函数学习笔记
    各个层次的gcc警告
    opencv3.2 dnn 图像分割
    ubuntu16.04 安装caffe以及python接口
    linux profileashrcash_profile之间的区别和联系
    ubuntu 16.04 安装pycharm
    Ubuntu下配置samba实现文件夹共享
  • 原文地址:https://www.cnblogs.com/shanmu/p/2145950.html
Copyright © 2011-2022 走看看