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

查看:37
本文介绍了带有 IE11 polyfill 导入的 Starter 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 start

4) do: npm start

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)

我尝试过其他 polyfill:

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.

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

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 导入的 Starter create-react-app 仍然在 IE11 中中止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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