带有IE11 polyfill导入的入门级create-react-app在IE11中仍然中止 [英] Starter create-react-app with IE11 polyfill import still aborts in IE11

查看:289
本文介绍了带有IE11 polyfill导入的入门级create-react-app在IE11中仍然中止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using: react 16.8.6. Working in: Dev Mode.

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

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

2)cd my-app

2) cd my-app

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

3) add: import "react-app-polyfill/ie11"; as the new first line in index.js

4)做:npm开始

5)在Windows 10的IE11中,它会在控制台中终止:

5) In IE11 on Windows 10 it aborts with these in the console:

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

SCRIPT1002: Syntax error 1.chunk.js (10735,34)

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

SCRIPT1002: Syntax error main.chunk.js (154,1)

我尝试了其他polyfills:

I have tried other polyfills:

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

import "react-app-polyfill/ie9";

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

import 'react-app-polyfill/stable';

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

import 'react-app-polyfill/ie9'; import 'react-app-polyfill/stable';

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

import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable';

语法错误的位置发生了变化,但仍然会发生.

The location of the Syntax error changes, but it still happens.

在所有其他浏览器中都可以正常工作.

Works fine in all other browsers.

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中的旧版死亡白屏".

The abort happens immediately before the generated code ever loads. It gives the old 'White screen of death' in IE11.

任何人都可以分享使16.8.6入门版应用程序在IE11中工作的魔力吗?

Can anyone share the magic to get the 16.8.6 starter app to work in IE11?

推荐答案

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

You can refer to the following steps to support IE11:

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

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

Second, add import 'react-app-polyfill/ie11'; import 'react-app-polyfill/stable'; at the first line in src/index.js.

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

Third, add ie 11 in package.json like this: 

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

Finally, you can restart your app and it will work in IE11. If it still doesn't work, delete the app and create it again according to the above steps.

这篇关于带有IE11 polyfill导入的入门级create-react-app在IE11中仍然中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆