【问题标题】:IE8 returns 'Object expected' [].slice.call [duplicate]IE8 返回“预期对象”[].slice.call [重复]
【发布时间】:2015-11-26 10:38:11
【问题描述】:

我是 js 新手,此代码在除 li 元素(选项卡)之外的所有浏览器上都运行良好。

	(function() {

	  [].slice.call(document.querySelectorAll('.tabs')).forEach(function(el) {
	    new CBPFWTabs(el);
	  });

	})();

有什么帮助吗?

【问题讨论】:

  • 更新:将 [].slice.call(document.querySelectorAll('.tabs')) 更改为 [].slice.call(document.getElementsByClassName("tabs")) 仍然是同样的错误。

标签: javascript internet-explorer-8


【解决方案1】:

IE8 部分支持querySelectorAll()http://caniuse.com/#feat=queryselector

也请阅读:querySelectorAll alternative for IE

【讨论】:

  • 不是 [].slice.call 有问题吗?它在“字符 3”上显示错误
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-24
  • 2016-04-15
  • 2013-05-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多