getDom方法可以获得文档中的DOM节点,该方法中包含一个参数,该参数能够是DOM节点的id、DOM节点对象或DOM节点对应的Ext元素(Element)等。 (与getElementById是一个效果)dom
•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> 文档
•get
在上面的代码中,Ext.getDom("hello")、Ext.getDom(e)、Ext.getDom(e.dom)等三个语句返回都是同一个DOM节点对象。it
•get方法中只有一个参数,这个参数是混合参数,能够是DOM节点的id、也能够是一个Element、或者是一个DOM节点对象等。io
•get方法实际上是Ext.Element.get的简写形式。 function
•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> di
•Ext.get("hello")、Ext.get(document.getElementById("hello"))、Ext.get(e)等三个方法均可以获得一个与DOM节点hello对应的Ext元素。document
•getCmp方法用来得到一个Ext组件,也就是一个已经在页面中初始化了的Component或其子类的对象,getCmp方法中只有一个参数,也就是组件的id。
•getCmp方法实际上是Ext.ComponentMgr.get方法的简写形式。
•Ext.onReady(function(){
var myPanel=new Ext.Panel({
id:“myFirstPanel”,
title:“旧的标题",
renderTo:"hello",
width:300,
height:200
});
Ext.getCmp(" myFirstPanel ").setTitle("新的标题");
});
•//Html页面中包含一个id为hello的div,代码以下:
<div id="hello">aaa</div>
•咱们使用Ext.getCmp(“myFirstPanel").来获得id为myFirstPanel的组件,并调用其setTitle方法来设置该面板的标题