如何使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
更改为(我认为)暗示它应该构建适当的polyfills.
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 is not a function
和Object doesn't support property or method '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'; // core-js@^3.1.4
更新
tsconfig.json
polyfills.ts
这篇关于如何使Angular 8与IE11兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!