admin管理员组文章数量:1534340
var eSpread, eWrap;
eWrap = document.querySelectorAll('.list-group-item[ng-repeat]');
eWrap.forEach(function(item) {
eSpread = document.createElement('i');
eSpread.classList.add('cus-glyphicon', 'glyphicon-menu-down');
eSpread.addEventListener('click', function(event) {
event.preventDefault();
event.stopPropagation();
angular.element(item).toggleClass('spread');
}, true);
item.appendChild(eSpread);
});
eWrap = document.querySelectorAll(’.list-group-item[ng-repeat]’);
在谷歌和360极速浏览器的极速模式下,都显示eWrap是个nodeList,但在360下报错。
查找资料信息
querySelectorAll的兼容性
forEach的兼容性
nodeList.forEach
最近发生该错误的版本是:谷歌浏览器47;
eWrap是有值的,是一个nodeList,伪数组;
forEach是用来遍历数组的,但也可以遍历nodeList;
eWrap.forEach在谷歌中报错,但在ie11中就忽略掉了;
因此,这个问题就是浏览器兼容性问题了,解决办法有两种:
1、把伪数组转化为一个数组;
2、使用兼容性更高的api,比如angular.foreach();
3、在HTML的集合的上下文里先声明是一个数组,比如下面的方法:
[].forEach.call(eWrap, function(item) { }
版权声明:本文标题:360极速浏览器中的极速模式下,报错:eWrap.forEach is not a function 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1726884028a1088774.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论