【问题标题】:Angular 5 and IE11 problems that requires shims for IE需要 IE 填充程序的 Angular 5 和 IE11 问题
【发布时间】:2019-03-08 03:26:30
【问题描述】:

我正在使用 Angular 5 并尝试在 IE11 中运行我的应用程序。我已取消注释 .\my-app\src\polyfills.ts 中的必要代码,但不幸的是,在我的 index.html 文件中收到与此代码相关的以下错误:

<script>
  System.import('main.js').catch(function(err){ console.error(err); });
</script>

Error: 'System' is undefined

我环顾四周,发现以下 Github 问题有可能修复:

https://github.com/angular/angular/issues/7144

在这个线程中,它提到我需要在我的 index.html 文件中包含这个:

shims_for_IE.js

现在,我正在使用 Angular 5,但我不确定在哪里可以找到这个 shims_for_IE.js 文件,以便将它放在我的 index.html 文件中。

如何在 IE11 中解决 'System' is undefined 问题?

【问题讨论】:

  • 从浏览器列表文件的not IE 9-11 行中删除not 关键字
  • @AbhayGawade 抱歉,不确定在哪里可以找到此浏览器列表文件以删除 not 关键字

标签: javascript angular internet-explorer-11


【解决方案1】:

对于非 CLI

对于非 CLI 项目,在 index.html 中导入 shim.min.js

<script src="node_modules/core-js/client/shim.min.js"></script>

对于 CLI

在您的polyfills.ts 中取消注释这些行

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE9, IE10, IE11, and Chrome <55 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/weak-map';
import 'core-js/es6/set';

index.html文件中添加这个元标记here

 <meta http-equiv="X-UA-Compatible" content="IE=edge" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-25
    • 1970-01-01
    • 1970-01-01
    • 2011-09-27
    • 1970-01-01
    • 2012-10-28
    • 1970-01-01
    • 2012-06-30
    相关资源
    最近更新 更多