【问题标题】:SCRIPT1014 and SCRIPT1002 error in Angular4 application with IE11带有 IE11 的 Angular4 应用程序中的 SCRIPT1014 和 SCRIPT1002 错误
【发布时间】:2017-08-29 03:44:23
【问题描述】:

我的 Angular 4 应用程序可以在不同的浏览器中完美运行。在 Internet Explorer 版本 11 中运行任何 Angular 4 应用程序时,启动应用程序时出现以下两个错误:

SCRIPT1014: Invalid character
addScript.js (9,1)

SCRIPT1002: Syntax error
main.bundle.js (52,1)

请需要任何帮助来解决此问题。先感谢您。 注意:我尝试过使用 Angular 2 的 shims 解决方案,但它并没有真正起作用,即 shims_for_IE。如果我需要以不同的方式处理它,请告诉我。

我当前的 polyfill:

import 'core-js/es6/symbol'; 
import 'core-js/es6/object'; 
import 'core-js/es6/typed'; 
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'; 
import 'core-js/es6/reflect'; 
import 'core-js/es7/reflect'; 
import 'zone.js/dist/zone'; 

【问题讨论】:

  • 任何快速的解决方法都会非常有帮助。

标签: javascript angular internet-explorer-11


【解决方案1】:

要使Angular 应用程序可以在每个浏览器上运行,您可以使用Polyfill

当您使用Angular-CLI 生成项目时,它已经附带一个包含必要polyfills 的文件。您可以在 src/polyfill.ts 名称下找到此文件。

只需打开此文件并取消注释您需要的行(他们有充分的记录,他们正在描述需要polyfill 的浏览器),一旦完成,再次构建您的项目,强制您的浏览器在@987654327 上运行@,你准备好了。

【讨论】:

  • 我的 polyfills.ts 文件包含以下行。请让我知道是否应该包含或删除: import 'core-js/es6/symbol';导入'core-js/es6/object';导入'core-js/es6/typed';导入'core-js/es6/function';导入'core-js/es6/parse-int';导入'core-js/es6/parse-float';导入'core-js/es6/number';导入'core-js/es6/math';导入'core-js/es6/string';导入'core-js/es6/date';导入'core-js/es6/array';导入'core-js/es6/regexp';导入'core-js/es6/map';导入'core-js/es6/set';导入'core-js/es6/reflect';导入'core-js/es7/reflect';导入'zone.js/dist/zone';
【解决方案2】:

我遇到了与 SCRIPT1002 类似的问题:语法错误 main.bundle.js。

我的 polyfill.ts 文件是一样的。我最终通过添加一个空白 div 来编辑 index.html 文件,然后保存 html 文件,然后删除 div,然后再次保存。保存 html 文件后,重新加载 Angular cli,它可以与 IE11 一起使用。

【讨论】:

    猜你喜欢
    • 2019-10-09
    • 1970-01-01
    • 2021-11-11
    • 2018-11-09
    • 2019-04-04
    • 2020-05-21
    • 2018-01-03
    • 2018-05-20
    • 1970-01-01
    相关资源
    最近更新 更多