欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

Ext.js分析,

来源: javaer 分享于  点击 36380 次 点评:115

Ext.js分析,


enumerables = true,
enumerablesTest = { toString: 1 },
for (i in enumerablesTest) {
enumerables = null;
}

if (enumerables) {
enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable',
'toLocaleString', 'toString', 'constructor'];
}

要理解上面的话,得明白在ie下for i in obj 里,不能迭代toString等方法
Ext.apply = function(object, config, defaults) {
if (defaults) {
Ext.apply(object, defaults);
}

if (object && config && typeof config === 'object') {
var i, j, k;

for (i in config) { 拷贝配置属性到obj
object[i] = config[i];
}

if (enumerables) { //如果是ie
for (j = enumerables.length; j--;) {
k = enumerables[j];
if (config.hasOwnProperty(k)) { //拷贝enumerables里的非native
object[k] = config[k];
}
}
}
}

return object;
};

applyIf: function(object, config) { 拷贝config里object未定义的配置
var property;

if (object) {
for (property in config) {
if (object[property] === undefined) {
object[property] = config[property];
}
}
}

return object;
},

iterate: function(object, fn, scope) { 可以迭代对象和数组,执行fn方法
if (Ext.isEmpty(object)) {
return;
}

if (scope === undefined) {
scope = object;
}

if (Ext.isIterable(object)) {
Ext.Array.each.call(Ext.Array, object, fn, scope);
}
else {
Ext.Object.each.call(Ext.Object, object, fn, scope);
}
}

相关文章

    暂无相关文章

用户点评