我正在使用Angular CLI(1.1.2)构建一个Angular4项目。它在Chrome(版本59.0.3071.115)和firefox(54.0.1)中运行完美,但是当我尝试使用IE11(Verison 11.0.9600.18738)时,nothings出现并且当我在IE中打开开发模式时,它显示以下错误:
SCRIPT5022: Exception thrown and not caught
File: polyfills.bundle.js, Line: 829, Column: 34
详细的错误消息如下:
任何人都知道如何解决这个问题?
谢谢!
答案 0 :(得分:78)
为@ Zeqing的答案添加更多细节。
我在.\my-app\src\polyfills.ts
中取消注释以下代码行:
/** 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';
答案 1 :(得分:64)
默认的polyfills.ts文件已注释,需要取消注释代码行并运行npm install相应的模块。然后它将与IE11兼容
答案 2 :(得分:8)
当我尝试添加es7导入时,我得到了这个。我只是用es7导入替换了es6导入。结果我需要两者。
给我"异常抛出而未被抓住"错误:
import 'core-js/es7/array';
工作正常:
import 'core-js/es6/array';
import 'core-js/es7/array';
答案 3 :(得分:0)
在polyfills中取消对导入的注释后,您还必须安装一些软件包才能使应用程序正常运行。请检查以下链接:
https://blog.angularindepth.com/angular-and-internet-explorer-5e59bb6fb4e9