Babel does not translate Map() when using Create-React-App

时间:2017-08-04 12:40:24

标签: reactjs ecmascript-6 babel create-react-app

I have a React App using Create-React-App. I've used the Map() datastructure included in ES6 in my app. However, in IE11 it does not work. Shouldn't Babel (under the hood of Create-React-App - I did not eject) take care of this?

If not, is there there any solution for that?

2 个答案:

答案 0 :(得分:1)

正如其他人已经提到的那样,当有问题的浏览器本身不支持时,您需要使用polyfill来添加功能。由于您已经在使用Babel,最简单的方法是使用Babel polyfill。

如果您不想添加其他相关信息,则可以使用找到的Map polyfill here

答案 1 :(得分:-1)

No.

Use babel-polyfill for cross-browser babel support:

npm install --save babel-polyfill

If you're using webpack/browserify then here's how you should incorporate the polyfill:

module.exports = {
  entry: ["babel-polyfill", "./app/js"]
};

If you're still unclear, read the documentation here.