(1) apply () and applyif ()
Apply (): Copy all attribute values of an object to another object. var A = {Name: 'xiaosi', age: '23'}; var B = {Name: 'sjf', age: '24'}; Ext. apply (B, A); alert ("name:" + B. name + "Age:" + B. age); Result: Name: xiaosi age: 23 applyif (): Copies all attribute values of an object to another object. However, if a property already exists in the target object, ext. applyif () won't overwrite it. VaR A = {Name: 'xiaosi', age: '23', sex: 'male'}; var B = {Name: 'sjf', age: '24 '}; ext. applyif (B, A); alert ("name:" + B. name + "Age:" + B. age + "Sex:" + B. sex); Result: Name: xiaosi age: 23 Sex: Male
(2) Difference between get (), getdom (), and getcmp ()
The getdom method can get the DOM nodes in the document. This method contains a parameter, which can be the ID of the DOM node, the DOM Node object, or the ext element (element) corresponding to the DOM node. (Same as getelementbyid) • Ext. onready (function (){
VaR E = new Ext. element ("hello ");
Ext. getdom ("hello ");
Ext. getdom (E );
Ext. getdom (E. DOM );
}); • // The HTML page contains a div with the ID of hello. The Code is as follows:
<Div id = "hello"> AAA </div> •
In the above Code, ext. getdom ("hello"), ext. getdom (E), ext. getdom (E. DOM.
• The get method has only one parameter. this parameter is a hybrid parameter, which can be the ID of a DOM node, an element, or a DOM Node object. • The get method is short for Ext. element. Get. • Ext. onready (function (){
VaR E = new Ext. element ("hello ");
Ext. Get ("hello "));
Ext. Get (document. getelementbyid ("hello "));
Ext. Get (E );
}); • // The HTML page contains a div with the ID of hello. The Code is as follows:
<Div id = "hello"> AAA </div> • Ext. get ("hello"), ext. get (document. getelementbyid ("hello"), ext. get (E) and other three methods can get an ext element corresponding to the DOM node hello.
• The getcmp method is used to obtain an ext component, that is, a component that has been initialized on the page or its subclass object. The getcmp method has only one parameter, that is, the component ID. • The getcmp method is short for the Ext. componentmgr. Get method. • Ext. onready (function (){
VaR mypanel = new Ext. Panel ({
ID: "myfirstpanel ",
Title: "Old title ",
Renderto: "hello ",
Width: 300,
Height: 200
});
Ext. getcmp ("myfirstpanel"). settitle ("New title ");
}); • // The HTML page contains a div with the ID of hello. The Code is as follows:
<Div id = "hello"> AAA </div> • Ext. getcmp ("myfirstpanel "). to obtain the component whose ID is myfirstpanel, and call its settitle method to set the title of the Panel.