IE9 ReactJs中未定义“设置"或“映射" [英] 'Set' or 'Map' is undefined in IE9 ReactJs
问题描述
我用react 16.2.0创建了一个简单的应用程序,当我在IE9上执行/运行它时,显示控制台错误'Set'或'Map'未定义.
I have created a simple application with react 16.2.0 and when I execute/run it on IE9 it shows me console error 'Set' or 'Map' is undefined.
推荐答案
我发现需要一些polyfill才能在IE9上运行我的react应用程序.我遵循以下步骤,它为我工作.由于React 16取决于集合类型Map和Set.如果您支持可能还没有原生提供这些功能的较旧的浏览器和设备(例如IE< 11),请考虑在捆绑的应用程序中包括全局polyfill,例如core-js或babel-polyfill.
I have found that there are some polyfills require to run my react application on IE9. I followed following steps and it worked for me. As React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (e.g. IE < 11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.
我们还必须使用requeststrongationFrame polyfill库,该库是 raf
We also have to use requestAnimationFrame polyfill library which is raf
npm install --save raf
index.js
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'raf/polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, world!</h1>,
document.getElementById('root')
);
这篇关于IE9 ReactJs中未定义“设置"或“映射"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!