Angular 9 Internet Explorer 11 中的应用白屏和空白控制台

Angular 9 app white screen and empty console in Internet Explorer 11

Angular 应用的常见问题以及与 IE 的兼容性。只是白屏,控制台中没有错误。我看过很多类似的帖子,但到处都是相同的解决方案。 我已经尝试过的:

  1. polyfills.ts
import 'classlist.js';  // Run `npm install --save classlist.js`.
import'core-js/es/symbol';
import'core-js/es/object';
import'core-js/es/function';
import'core-js/es/parse-int';
import'core-js/es/parse-float';
import'core-js/es/number';
import'core-js/es/math';
import'core-js/es/string';
import'core-js/es/date';
import'core-js/es/array';
import'core-js/es/regexp';
import'core-js/es/map';
import'core-js/es/weak-map';
import'core-js/es/set';
import 'web-animations-js';  // Run `npm install --save web-animations-js`.
  1. tsconfig.json

     "target": "es5",
    
  2. index.html

    中的元标记
    <meta charset="utf-8" http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    
  3. 浏览器列表 删除了 not,现在只有 IE 9-11 # For IE 9-11 support, remove 'not'.

我仍然收到一个白屏,控制台中没有任何错误。我还能尝试什么?

根据您最后的评论,我们现在知道您遇到了 'URLSearchParams' is undefined polyfills-es5.js 错误。

您的代码似乎包含 IE 浏览器不支持的 URLSearchParams。这可能是错误的可能原因。

Polyfill 可用于 URLSearchParams。

我建议在你的项目中尝试使用这个 polyfill 可能会帮助你修复这个错误。

已找到解决方案,问题出在 @ngx-translate 库上。

我正在使用 "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "^6.0.0"

我降级到 12.0.0 和 5.0.0 并且有效。真的不知道为什么新版本与 IE11 不兼容,但现在我的 Angular 应用程序可以在 Chrome 和 IE11 上运行,没有任何错误。