在我的 JavaScript 中我有一个函数 detectEnvironmentAndGetLEAndDepot()
这叫做onload
通过 HTML。我正在使用 wicket,需要获取后端保存的值,所以我将它们显示到屏幕上,隐藏它们,然后搜索 <span>
我的 JS 中 name
的值值,例如 if(v.getAttribute('name') === 'LE'){do stuff}
或 if(v.getAttribute('name') === 'depot'){do stuff}
(我确定这不是最优雅的解决方案,但我需要一个快速的解决方案!)。然后在函数内 detectEnvironmentAndGetLEAndDepot()
我做了一些格式化等,以便数据可用。
detectEnvironmentAndGetLEAndDepot()
功能(很长,只有相关部分)-
detectEnvironmentAndGetLEAndDepot = function() {
Array.from(document.getElementsByTagName('span')).forEach(function(v) {
//Search name tag for particular names, then do formatting
}
当我在 IE11 中打开它时,我在弹出窗口中收到错误 SCRIPT438: Object doesn't support property or method 'from'
这与上述方法的第一行有关 - Array
类(class)。非常感谢帮助。
最佳答案
由于IE不支持Array.from
方法,您可以尝试使用:
[].slice.call(document.getElementsByTagName('span')).forEach(function(v) {});
这不需要使用任何第 3 方库。
关于javascript - IE 11 AngularJS 错误 - 对象不支持属性或方法 'from',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35576694/