【问题标题】:Does Angular 5 polyfill async / await for IE11Angular 5 polyfill async/await 是否适用于 IE11
【发布时间】:2019-02-27 18:27:49
【问题描述】:

我们开发了一款需要IE11支持的软件。正如多个来源所说,IE11 不支持 async/await:

还有几篇博客文章。

我们现在确实编写了一个使用 async/await 的简单 Angular 5 项目,它在 IE11 中运行良好。我们可以安全地假设 Angular 使用某种 polyfill 在 IE11 中添加对此的支持吗?我找不到任何说明 Angular 增加了对它的支持的来源。

【问题讨论】:

    标签: angular async-await ecmascript-2016


    【解决方案1】:

    从 TypeScript 2.1 开始,TypeScript 编译器支持 compiling async/await code down to a form that works even on IE6!

    因此,如果您的 tsconfig.json 的目标设置为 ES5 或更低(Angular CLI 项目中的默认情况),TypeScript 将为您处理此转换。您可能需要 polyfill 才能使用它的唯一功能是 Promise。

    【讨论】:

    • @newnoise: 没问题 :) 如果您想查看输出的代码类型,请转到 typescriptlang.org/play 并尝试输入一个空的 async 函数 - 您会感到惊讶有多少代码被吐出:p
    • Angular 7 项目是否需要提前编译?
    猜你喜欢
    • 2019-10-24
    • 2018-07-09
    • 2019-05-08
    • 1970-01-01
    • 2015-09-26
    • 2018-03-24
    • 1970-01-01
    • 1970-01-01
    • 2018-08-23
    相关资源
    最近更新 更多