【问题标题】:IE11: How to polyfill `Array.values().next()` in Internet explorer, in React?IE11:如何在 Internet Explorer 中的 React 中填充 `Array.values().next()`?
【发布时间】:2021-02-12 02:18:23
【问题描述】:

我的 React 项目在 IE11 中运行时遇到迭代器问题。

这是重现问题的最少代码量;

// index.js

...
import React from 'react'
import ReactDOM from 'react-dom'
import 'core-js'
import 'whatwg-fetch'
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

const a = [1,2,3,4].values().next();
console.log(a);
...

在 IE11 中,我收到一条错误提示

SCRIPT438: Object doesn't support property or method 'next'

我已经导入了整个 'core-js' 库,我还需要导入什么来在 IE11 中填充此功能?

【问题讨论】:

    标签: javascript reactjs internet-explorer-11 polyfills core-js


    【解决方案1】:

    import 'react-app-polyfill/ie11';
    import 'react-app-polyfill/stable';
    

    作为 index.js 中的 前两行 https://www.npmjs.com/package/react-app-polyfill

    【讨论】:

    • 并尝试不使用/ie11,以防这不能解决您的问题
    猜你喜欢
    • 2015-02-13
    • 1970-01-01
    • 2011-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-03
    • 2015-12-19
    • 2011-08-13
    相关资源
    最近更新 更多