Angular应用在IE浏览器中无法打开,而在Chrome中可以打开。
创始人
2024-10-30 16:00:27
0

解决这个问题的方法是添加Polyfills(垫片)来支持在IE浏览器中运行Angular应用。Polyfills是一组代码片段,它们为旧版本的浏览器模拟一些新特性。

以下是一个示例代码,演示如何在Angular应用中添加Polyfills来支持IE浏览器:

  1. 首先,安装polyfills库。在命令行中运行以下命令:
npm install --save core-js
  1. 在polyfills.ts文件中添加以下代码:
// Polyfills required to support running Angular applications on IE browsers

// Add global to window, assigning the value of window itself.
(window as any).global = window;

// Required for core-js/es7/reflect
import 'core-js/es7/reflect';

// Zone JS is required by Angular itself.
import 'zone.js/dist/zone';
  1. 在angular.json文件中,将polyfills.ts添加到polyfills数组中:
"scripts": [
  "src/polyfills.ts"
]
  1. 在tsconfig.json文件中,将"target"设置为"es5":
"compilerOptions": {
  "target": "es5",
  ...
}
  1. 最后,重新编译和运行Angular应用:
ng serve

现在,您的Angular应用应该能够在IE浏览器中正确运行了。请注意,这只是一个基本示例,实际应用可能需要更多的Polyfills和配置。

相关内容

热门资讯

黑科技科技(wepoke智能a... 黑科技科技(wepoke智能ai)wepower使用说明书(wepOkE)素来是真的有挂(确实有挂)...
黑科技模拟器(wepoke智能... WePoker透视辅助工具核心要点解析‌,黑科技模拟器(wepoke智能ai)wepoke是机器发牌...
黑科技脚本(wepokeai代... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在这款游戏中打牌都...
黑科技辅助挂(wepoke真的... 黑科技辅助挂(wepoke真的有挂)wepoke 软件(wEPOKE)固有真的有挂(有挂猫腻)-哔哩...
黑科技辅助挂(wepoke黑科... 黑科技辅助挂(wepoke黑科技)wepoke软件透明挂演示(wEpOke)一直真的有挂(真的有挂)...
黑科技app(wepoke真的... 此外,数据分析德州()辅助神器app还具备辅助透视行为开挂功能,通过对客户透明挂的深入研究,你可以了...
黑科技智能ai(wepoke辅... 黑科技智能ai(wepoke辅助插件)wepoke软件透明(WEPOke)先前是有挂(果真有挂)-哔...
黑科技模拟器(wepoke透明... 黑科技模拟器(wepoke透明黑科技)wepoke德州扑克用ai代打(WEPOKE)最初存在有挂(有...
黑科技插件(wepoke辅助插... 黑科技插件(wepoke辅助插件)wepoke软件透明(WEPOke)从来是真的有挂(有挂解惑)-哔...
黑科技美元局(wepoke智能... 黑科技美元局(wepoke智能ai)wepoke辅助真的假的(wepoKE)原先真的有挂(竟然有挂)...