33

我正在使用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中取消註釋代碼行註釋 –

回答

33

默認的polyfills.ts文件是註釋的,需要取消註釋代碼行並運行npm安裝相應的模塊。然後它將與IE11兼容

35

在@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

3

我得到這個,當我試圖添加一個ES7進口。我簡單地用es7導入替換了es6導入。原來我需要兩個。

給我 「拋出異常,而不是陷入」 錯誤:

import 'core-js/es7/array'; 

正常工作:

import 'core-js/es6/array'; 
import 'core-js/es7/array'; 
相關問題