如何使 Angular 8 与 IE11 兼容? [英] How do I make Angular 8 compatible with IE11?
问题描述
我使用 ng update
升级到 Angular 8.它运行了它的迁移脚本(除其他外)删除了 polyfills.ts
中的 es6/es7 导入.从我读到的内容来看,Angular 将为旧版浏览器(包括 IE11)创建一个特殊的构建版本,而且我不必再担心 polyfills 了?我将 browserlist
更新为 not IE 9-10
而不是 not IE 9-11
以(我认为)暗示它应该构建适当的填充物.
I upgraded to Angular 8 using ng update
. It ran its migration scripts which (among other things) removed the es6/es7 imports in polyfills.ts
. From what I read, Angular will create a special build for older browsers (including IE11) and I don't have to worry about polyfills anymore? I updated browserlist
to be not IE 9-10
instead of not IE 9-11
to (I presume) hint that it should build the appropriate polyfills.
不幸的是,在运行 ng build
后,我遇到了一些与 polyfill 相关的错误,例如.Reflect.getMetadata 不是函数
并且Object 不支持属性或方法'includes'
.我尝试将 reflect
和 array
导入放回 polyfills 并跳过这些错误,但我得到了其他错误.这是怎么回事?我应该包含 polyfills 还是不包含?
Unfortunately, after running ng build
, I get some polyfill related errors, eg. Reflect.getMetadata is not a function
and Object doesn't support property or method 'includes'
. I tried putting reflect
and array
imports back into polyfills and move past those errors, but I get others. What's the deal? Am I supposed to include polyfills or not?
如何使 Angular 8 与 IE11 一起使用?
How do I make Angular 8 work with IE11?
推荐答案
让 IE 11 与 Angular 8 一起工作的一种方法是禁用差异加载.
One way to get IE 11 to work with Angular 8 is to disable differential loading.
执行以下操作:
- 使用
"target": "es5"
更新 - 使用
import 'core-js' 更新
polyfills.ts
;//core-js@^3.1.4
tsconfig.json
- Update
tsconfig.json
with"target": "es5"
- Update
polyfills.ts
withimport 'core-js'; // core-js@^3.1.4
这篇关于如何使 Angular 8 与 IE11 兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!