关于reactjs:带有IE11 polyfill导入的Starter create-react-app在IE11中仍然中止

Starter create-react-app with IE11 polyfill import still aborts in IE11

使用:反应16.8.6。
工作于:开发模式。

1)做:npm create-react-app my-app

2)cd我的应用

3)添加:导入" react-app-polyfill / ie11";作为index.js中的新第一行

4)做:npm开始

5)在Windows 10的IE11中,它在控制台中中止了这些操作:

SCRIPT1002:语法错误
1.chunk.js(10735,34)

SCRIPT1002:语法错误
main.chunk.js(154,1)

我尝试了其他polyfills:

导入" react-app-polyfill / ie9";

导入" react-app-polyfill / stable";

导入'react-app-polyfill / ie9';
导入" react-app-polyfill / stable";

导入'react-app-polyfill / ie11';
导入" react-app-polyfill / stable";

语法错误的位置已更改,但仍会发生。

在所有其他浏览器上都可以正常工作。

1
2
3
4
5
6
7
8
9
import"react-app-polyfill/ie11";
import React from"react";
import ReactDOM from"react-dom";
import"./index.css";
import App from"./App";
import * as serviceWorker from"./serviceWorker";
import"bootstrap/dist/css/bootstrap.css";

ReactDOM.render(<App />, document.getElementById("root"));

该中止将在加载生成的代码之前立即发生。它在IE11中提供了旧的"死亡白屏"。

谁能分享魔力,让16.8.6入门版应用程序在IE11中工作?


您可以参考以下步骤来支持IE11:

首先,安装软件包:npm install react-app-polyfill

其次,在src / index.js的第一行添加import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';

第三,像这样在packge.json中添加ie 11

enter image description here

最后,您可以重新启动应用程序,它将在IE11中运行。 如果仍然无法使用,请删除该应用,然后根据上述步骤重新创建。


https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md

yarn add react-app-polyfill

1
2
3
4
5
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

// ...