ExtJs 5.0:对象数组上的 forEach 在 IE8 中不起作用
ExtJs 5.0 : forEach on Array of Objects not working in IE8
我有一个简单的模型 -
Ext.define('MyModel', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.field.String'
],
fields: [
{
type: 'string',
name: 'currentA'
},
{
type: 'string',
name: 'currentB'
},
{
name: 'A'
},
{
name: 'B'
}
]
});
这是我正在对该模型的数据执行的一些操作-
onBeforeRender: function(component, eOpts) {
var mystore = Ext.getStore('Mystore');
mystore.load({
callback: function(){
var entity = headerStore.getAt(0);
var bs = entity.data.B;
var as = entity.data.A;
var currentB = entity.data.currentB;
var currentA = entity.data.currentA;
bs.forEach(function(record) {
// do some operations
});
as.forEach(function(record) {
// do some other operations
});
}
});
}
现在,当遍历显然是对象数组的变量 "bs" 时,IE 8 会报错
"Object doesn't support this property or method"
forEach 函数。这在 Chrome.
中工作正常
这是模型的 json -
{
"currentA": "a",
"currentB": "b",
"A": [
{
"name": "a",
"id": 1
}
],
"B": [
{
"name": "b",
"id": 2
}
]
}
为什么 IE 无法将其识别为数组?
我有一个简单的模型 -
Ext.define('MyModel', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.field.String'
],
fields: [
{
type: 'string',
name: 'currentA'
},
{
type: 'string',
name: 'currentB'
},
{
name: 'A'
},
{
name: 'B'
}
]
});
这是我正在对该模型的数据执行的一些操作-
onBeforeRender: function(component, eOpts) {
var mystore = Ext.getStore('Mystore');
mystore.load({
callback: function(){
var entity = headerStore.getAt(0);
var bs = entity.data.B;
var as = entity.data.A;
var currentB = entity.data.currentB;
var currentA = entity.data.currentA;
bs.forEach(function(record) {
// do some operations
});
as.forEach(function(record) {
// do some other operations
});
}
});
}
现在,当遍历显然是对象数组的变量 "bs" 时,IE 8 会报错
"Object doesn't support this property or method"
forEach 函数。这在 Chrome.
中工作正常这是模型的 json -
{
"currentA": "a",
"currentB": "b",
"A": [
{
"name": "a",
"id": 1
}
],
"B": [
{
"name": "b",
"id": 2
}
]
}
为什么 IE 无法将其识别为数组?