[英]Babel does not translate Map() when using Create-React-App
I have a React App using Create-React-App. 我有一个使用Create-React-App的React App。 I've used the
Map()
datastructure included in ES6 in my app. 我在我的应用程序中使用了ES6中包含的
Map()
结构。 However, in IE11 it does not work. 但是,在IE11中它不起作用。 Shouldn't Babel (under the hood of Create-React-App - I did not eject) take care of this?
Babel(在Create-React-App的掩护下-我没有弹出)不应该照顾这个吗?
If not, is there there any solution for that? 如果没有,那有什么解决办法吗?
As others already mentioned, you are going to need a polyfill to add the functionality when it's not natively supported by the browser in question. 正如其他人已经提到的那样,当相关浏览器本身不支持该功能时,您将需要使用polyfill来添加该功能。 Since you're already using Babel, the easiest way to do this is by using a Babel polyfill.
由于您已经在使用Babel,因此最简单的方法是使用Babel polyfill。
If you don't want to add another dependency, you can use the Map
polyfill found here . 如果您不想添加其他依赖项,则可以使用在此处找到的
Map
polyfill。
No. 没有。
Use babel-polyfill
for cross-browser babel support: 将
babel-polyfill
用于跨浏览器的babel支持:
npm install --save babel-polyfill
If you're using webpack/browserify then here's how you should incorporate the polyfill: 如果您使用的是webpack / browserify,则应采用以下方式合并polyfill:
module.exports = {
entry: ["babel-polyfill", "./app/js"]
};
If you're still unclear, read the documentation here . 如果您仍然不清楚,请阅读此处的文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.