Angular4应用程序在IE11中运行问题

问题描述:

我正在使用Angular CLI构建Angular4项目(1.1.2)。它在Chrome(版本59.0.3071.115)和firefox(54.0.1)中运行得很完美,但是当我试图使用IE11(Verison 11.0.9600.18738)时,出现了问题,当我在IE中打开展开模式时,它向我显示以下错误:Angular4应用程序在IE11中运行问题

SCRIPT5022: Exception thrown and not caught 
File: polyfills.bundle.js, Line: 829, Column: 34 

而详细的错误消息如下:

enter image description here

任何人知道如何解决这个问题?

谢谢!

+2

的src/polyfills.ts –

+1

谢谢!我刚想通了,我需要在polyfills.ts中取消注释代码行注释 –

默认的polyfills.ts文件是注释的,需要取消注释代码行并运行npm安装相应的模块。然后它将与IE11兼容

在@Zeqing答案上添加更多详细信息。

我未评论代码的下面一行:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/ 
import 'core-js/es6/symbol'; 
import 'core-js/es6/object'; 
import 'core-js/es6/function'; 
import 'core-js/es6/parse-int'; 
import 'core-js/es6/parse-float'; 
import 'core-js/es6/number'; 
import 'core-js/es6/math'; 
import 'core-js/es6/string'; 
import 'core-js/es6/date'; 
import 'core-js/es6/array'; 
import 'core-js/es6/regexp'; 
import 'core-js/es6/map'; 
import 'core-js/es6/set'; 
+0

当我在VS 2017中添加了一个Angular CLI模板应用程序时为我工作 – Steve

+0

您可能导入的内容比您需要的要多,并且会扩大您的包的大小。截至2018年3月,一个新的cli项目将在IE11上正常运行,除es6/string和es6/array外,所有这些注释都已被注释掉。 – adamdport

我得到这个,当我试图添加一个ES7进口。我简单地用es7导入替换了es6导入。原来我需要两个。

给我 “抛出异常,而不是陷入” 错误:

import 'core-js/es7/array'; 

正常工作:

import 'core-js/es6/array'; 
import 'core-js/es7/array';