【发布时间】:2020-02-28 13:45:17
【问题描述】:
如何为 ie11 的 String.repeat 方法添加 polyfill?我没有直接在我的代码中使用它,它可能是一些导入的库。
在 IE 控制台中出现此错误:Object doesn't support property or method 'repeat'
我也得到了'AbortController' is undefined,我也没有使用我的代码,可能又是外部库。
我正在使用 create react app 并在 index.js 中导入:
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
我尝试将 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat#Polyfill 添加到我的 index.js 中,但它没有做任何事情。
其他人有类似的问题吗?
【问题讨论】:
-
为 IE 使用 polyfill 对我有用。
-
你是否在 index.js 的第一行导入了 polyfill?您是否按照this answer 中的步骤支持 IE 11 中的 React 应用程序?此外,您可以将this polyfill 用于
AbortController。如果还是不行,请提供a minimal, reproducible code sample,以便我们进行测试,看看如何提供帮助。
标签: javascript reactjs internet-explorer-11 create-react-app polyfills