如何使Angular 8与IE11兼容? [英] How do I make Angular 8 compatible with IE11?

查看:353
本文介绍了如何使Angular 8与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 functionObject doesn't support property or method 'includes'.我尝试将reflectarray导入放回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.

执行以下操作:

  1. 使用"target": "es5"
  2. 更新tsconfig.json
  3. 使用import 'core-js'; // core-js@^3.1.4
  4. 更新polyfills.ts

这篇关于如何使Angular 8与IE11兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆