为什么 Internet Explorer 不支持 includes()?

Why does Internet Explorer not support includes()?

我正在尝试支持跨浏览器兼容性,但 IE ( Internet Explorer ) 不支持函数 includes() 。有谁知道为什么会这样?

Array.prototype.includes and String.prototype.includes is part of the ES7 (now ES2017) and ES6 (now ES2015)javascript规格分别

来自 wikipedia:

Internet Explorer ... is a discontinued series of graphical web browsers

关键字:停产。微软现在只开发Edge。 IE 可能仍会获得安全更新,但它将不再收到新的 javascript 更新或任何浏览器规范更新。


includes() is not supporting in Internet Explorer , can you explain me why ?

Internet Explorer 不支持 Array.prototype.includesString.prototype.includes,因为 Microsoft 不再开发 IE。这些规格是在 Microsoft 停止使用 IE 之后发布的,因此,它不会获得这些功能。

稍等

您仍然可以在旧浏览器中使用新的 javascript,方法是使用 polyfills

您可以使用 core-js 作为 polyfill 库。

要在 IE 中使用 includes(...),只需在任何脚本 .

之前将其包含在 <head> 的顶部
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.min.js"></script>