ExtJS learning ------------ infrastructure, Extjs. js and Ext-more.js Learning
Ext. apply and Ext. applyIf
Ext. onReady (function () {// Ext. apply and Ext. applyIf extends var src1 = {name: 'zhang san', age: 23} to object attributes or methods; // The expanded object var src2 = {name: 'zhang san ', age: 23}; // The expanded object var config = {name: 'lily', sex: 'male'}; // configure the object // use Ext. apply is extended and will overwrite the original property or method Ext. apply (src1, config); for (var attr in src1) {alert (attr + ':' + src1 [attr]);} // use Ext. if this attribute or method exists, Ext is not replaced. applyIf (src2, config); for (var attr in src2) {alert (attr + ':' + src2 [attr]) ;}});
Result:
<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PC9wPgo8cD5FeHQub3ZlcnJpZGW3vbeoo6i4srjHo6k8L3A + CjxwcmUgY2xhc3M9 "brush: java;"> Ext. onReady (function () {Ext. define ('user', {say: function () // defines the method {alert ('say... ') ;}}); var user = Ext. create ('user'); Ext. override (user, {// method override say: function () {alert ('This is the override method... ') ;}}); user. say (); // call method });
Result:
Other methods:
Ext. onReady (function () {// typeof method, similar to var str = 'string' in javascript; alert ('Type: '+ Ext. typeOf (str); // isArray is... for more information, see the help documentation var arr = [1, 2]; alert (Ext. isArray (arr); // iterate method, traversing Ext. iterate (arr, function (item) {alert (item );});});
Result: