ie8 对象不支持 extjs 代码
ie8 Object doesn't support this for extjs code
- 我收到以下错误:“
Object doesn't support this
property or method
”在 ie8 中
- 在 chrome 很好
- 当我在 ie8 中调试 ext js 代码时,它显示 undefined for
region.getWorld();
- 但是当我在 chrome 浏览器中看到它时,我得到的是值
- 下面提供我的代码,你们能告诉我问题是什么吗
allWidth: function() {
var me = this,
states = me.getstates(),
waterY = 0,
placeY = 0,
World;
states.forEach(function(region) {
World = region.getWorld();
if (World.y < placeY) {
placeY = World.y;
}
if (World.y + World.height > waterY) {
waterY = World.y + World.height;
}
});
return waterY - placeY;
},
IE8 不支持数组的 forEach
方法。您有几个选项可以解决此问题。
您可以使用普通的 for 循环:
for(var i = 0; i < states.length; i++){
var region = states[i];
/* ... */
由于您使用的是 extjs,因此您也可以改用 Ext.each
方法:
Ext.each(states, function(region){
...
或者您可以使用 shim/polyfill 在 IE8 中添加 forEach
方法。
您可以在 MDN here.
上找到 forEach
方法的 polyfill
- 我收到以下错误:“
Object doesn't support this property or method
”在 ie8 中
- 在 chrome 很好
- 当我在 ie8 中调试 ext js 代码时,它显示 undefined for
region.getWorld();
- 但是当我在 chrome 浏览器中看到它时,我得到的是值
- 下面提供我的代码,你们能告诉我问题是什么吗
allWidth: function() {
var me = this,
states = me.getstates(),
waterY = 0,
placeY = 0,
World;
states.forEach(function(region) {
World = region.getWorld();
if (World.y < placeY) {
placeY = World.y;
}
if (World.y + World.height > waterY) {
waterY = World.y + World.height;
}
});
return waterY - placeY;
},
IE8 不支持数组的 forEach
方法。您有几个选项可以解决此问题。
您可以使用普通的 for 循环:
for(var i = 0; i < states.length; i++){
var region = states[i];
/* ... */
由于您使用的是 extjs,因此您也可以改用 Ext.each
方法:
Ext.each(states, function(region){
...
或者您可以使用 shim/polyfill 在 IE8 中添加 forEach
方法。
您可以在 MDN here.
上找到forEach
方法的 polyfill