简体   繁体   English

即使使用 polyfill,Angular 8 也无法在 IE11 中工作

[英]Angular 8 not working in IE11 even with polyfills

I have an angular 8 project and have included the core-js poly fills in my polyfills.ts file.我有一个 angular 8 项目,并且在我的 polyfills.ts 文件中包含了 core-js 多边形填充。

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
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/weak-map';
import 'core-js/es6/set';

When I load the app up in IE11, I get an error that says Object expected at tick in vendor-es5.js on line 130k当我在 IE11 中加载应用程序时,我收到一条错误消息,提示 Object 预计在第 130k 行的 vendor-es5.js 中出现

I started commenting out my code and noticed it was breaking when I used a for...of loop.我开始注释掉我的代码,并注意到当我使用for...of循环时它被破坏了。 If I change the loop to something like a .forEach the issue goes away.如果我将循环更改为.forEach之类的东西,问题就会消失。 Problem is I have a ton of for...of loops throughout my code and I like the fact I can break out of the loop using a return问题是我的代码中有大量for...of循环,我喜欢我可以使用return跳出循环的事实

Any ideas?有任何想法吗? Been trying to figure this out since Friday.自周五以来一直试图解决这个问题。 I'm sure I can change all my code to use forEach, but I feel like I'm missing something simple.我确信我可以将所有代码更改为使用 forEach,但我觉得我缺少一些简单的东西。

EDIT: Added how I am initializing the object.编辑:添加了我如何初始化 object。

mcgs = {};

constructor(private configService: ConfigService, private router: Router, private sanitizer: DomSanitizer) {}

ngOnInit() {
  this.configService.getMcgData().subscribe((response) => {
    this.mcgs = response; <-- might be an issue.
    ......

IE11 doesn't support for-of or anything else in ES2015+ (except for some slightly incorrect support for let and const ). IE11 不支持 ES2015+ 中for-of或其他任何内容(除了对letconst的一些稍微不正确的支持)。

If you want your project to run in IE11, you need not to use for-of , or to transpile your code to ES5 with a tool like Babel .如果您希望您的项目在 IE11 中运行,则无需使用for-of或使用Babel之类的工具将代码转换为 ES5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM