【问题标题】:promise not define in IE11 in angular 9 app承诺未在 Angular 9 应用程序的 IE11 中定义
【发布时间】:2020-07-06 20:17:41
【问题描述】:

我刚刚创建了一个 Angular 9 应用程序,但它无法在 IE11 中加载。 我已经添加了所有需要的 polyfill,包括用于 polyfill 承诺的“core-js/es/promise”。 但是 IE11 仍然在抱怨“未定义的承诺”。 为什么 Angular 团队仍然没有在他们的 polyfill 文件中添加那个 polyfill? 我们在 es5 中编译我们的代码。 我查看了互联网并得到了目前不适用的旧答案。 根据公司政策,我不能在我的 index.html 文件中包含任何 cdn 链接。 我错过了什么吗?

【问题讨论】:

  • 您是在 IE11 中检查 Angular 的开发版本还是产品版本?
  • 两者都不起作用。
  • 如果我们不知道您有什么,我们怎么知道您是否遗漏了什么?显示您的配置文件,分享您的构建和部署方式,分享确切的错误消息等。
  • 错误信息到底是什么?
  • 这能回答你的问题吗? 'Promise' is undefined error when run on IE

标签: angular internet-explorer-11


【解决方案1】:

在您的 polyfills.ts 中取消注释以下导入。 /** IE9、IE10 和 IE11 需要以下所有 polyfill。 **/

 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';

如果它不起作用,请执行以下操作。 在 tsconfig.json 文件中将编译器输出更改为 ES5:

{
  "compilerOptions": {
    "target": "es5"
  }
}

【讨论】:

    猜你喜欢
    • 2021-11-13
    • 1970-01-01
    • 2020-11-05
    • 2017-07-20
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    相关资源
    最近更新 更多