喜欢:
var result = eval('(' + response + ')');
var html = value = '';
for(item in result)
{
}
response
是一个 json 响应。
在 IE8 中,它停在 for..
处。
如何解决这个问题?
编辑
运行时出现同样的错误:
result = [1,2,3];
for(item in result)
{
...
}
最佳答案
我测试了 JavaScript For...In Statement 中的代码在 IE8 中没有问题。
绝对不是循环的问题(在 IE8 中不起作用),而是“结果”对象中的内容。
更新:
我发现了这个问题。
在 IE8 中(不确定其他 IE 版本),“item”这个词在某种程度上是一个保留词或其他东西。
这会起作用:
var item;
for(item in result)
{
...
}
这不会(如果 item
未声明):
for(item in result)
{
...
}
这会起作用:
for(_item in result)
{
...
}
关于javascript - IE8 会报 for in 没有声明 var item 的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1872177/