带有 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 start
5) 在 Windows10 上的 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';
语法错误的位置发生了变化,但它仍然会发生。
在所有其他浏览器中工作正常。
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 中给出了旧的 'White screen of death'。
任何人都可以分享让 16.8.6 入门应用程序在 IE11 中运行的魔法吗?
您可以参考以下步骤支持IE11:
首先,安装包:npm install react-app-polyfill
。
其次,在src/index.js.
的第一行添加import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';
第三,在package.json中添加ie 11
,像这样:〇
最后,您可以重新启动您的应用程序,它将在 IE11 中运行。如果还是不行,删除app,按照上述步骤重新创建。
https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md
yarn add react-app-polyfill
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
// ...
截至 2020 年底,react-scripts
4.0.0 似乎与 react-app-polyfill
和 IE 11 存在问题,详见 https://github.com/facebook/create-react-app/issues/9906。
我的解决方法,在我的 index.js 顶部(上面的 link 中显示了多个其他方法)
// https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill
import 'react-app-polyfill/ie11'
// https://github.com/facebook/create-react-app/issues/9906
// this is currently borked -> import 'react-app-polyfill/stable'
// so use core-js.. which might be the "right" way now per
// https://reactjs.org/docs/javascript-environment-requirements.html
import 'core-js/stable'
使用:反应 16.8.6。 工作于:开发模式。
1) 执行:npm create-react-app my-app
2) cd 我的应用程序
3)添加:导入"react-app-polyfill/ie11";作为 index.js
中新的第一行4) 执行:npm start
5) 在 Windows10 上的 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';
语法错误的位置发生了变化,但它仍然会发生。
在所有其他浏览器中工作正常。
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 中给出了旧的 'White screen of death'。
任何人都可以分享让 16.8.6 入门应用程序在 IE11 中运行的魔法吗?
您可以参考以下步骤支持IE11:
首先,安装包:npm install react-app-polyfill
。
其次,在src/index.js.
的第一行添加import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';
第三,在package.json中添加ie 11
,像这样:〇
最后,您可以重新启动您的应用程序,它将在 IE11 中运行。如果还是不行,删除app,按照上述步骤重新创建。
https://github.com/facebook/create-react-app/blob/master/packages/react-app-polyfill/README.md
yarn add react-app-polyfill
// These must be the first lines in src/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
// ...
截至 2020 年底,react-scripts
4.0.0 似乎与 react-app-polyfill
和 IE 11 存在问题,详见 https://github.com/facebook/create-react-app/issues/9906。
我的解决方法,在我的 index.js 顶部(上面的 link 中显示了多个其他方法)
// https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill
import 'react-app-polyfill/ie11'
// https://github.com/facebook/create-react-app/issues/9906
// this is currently borked -> import 'react-app-polyfill/stable'
// so use core-js.. which might be the "right" way now per
// https://reactjs.org/docs/javascript-environment-requirements.html
import 'core-js/stable'