C'est La Vie

    人生无彩排,每一天都是现场直播!

    旧版浏览器(e.g. IE < 11)中的 React

    在一些旧版浏览器中,你的 ES6 React 代码会报出如下错误: Warning: React depend […]

    在一些旧版浏览器中,你的 ES6 React 代码会报出如下错误:

    Warning: React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills

    比如,截图如下:

    原因是因为 React 需要 ES6 中的 Map 和 Set 两种数据类型。

    按照官方的方法,解决如下:

    # npm i --save core-js

    然后在你的代码中:

    import 'core-js/es6/map';
    import 'core-js/es6/set';

    就 OK 啦 ?

    下面附上官网上解决方法的截图

    发表回复

    您的电子邮箱地址不会被公开。 必填项已用*标注