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和配置。

相关内容

热门资讯

透视新版!hhpoker真的有... 透视新版!hhpoker真的有透视吗,pokermaster破解版,策略教程(果然是有挂)-哔哩哔哩...
透视实测!epoker免费透视... 透视实测!epoker免费透视脚本(透视)开挂辅助技巧(确实真的有挂)-哔哩哔哩1、下载好epoke...
透视软件!wejoker辅助机... 透视软件!wejoker辅助机器人(透视)开挂辅助器(原来有挂)-哔哩哔哩1、下载好wejoker辅...
透视好牌!steampoker... 透视好牌!steampokermaster辅助,wepoker辅助软件价格,指南书教程(总是真的有挂...
透视检测!wepoker有没有... 透视检测!wepoker有没有插件(透视)开挂辅助方法(一直有挂)-哔哩哔哩1、每一步都需要思考,不...
透视透视!aapoker辅助怎... 透视透视!aapoker辅助怎么用,hhpoker一直输有挂吗,模块教程(一贯存在有挂)-哔哩哔哩该...
透视脚本!wepoker私人局... 透视脚本!wepoker私人局俱乐部怎么进(透视)开挂辅助插件(切实真的是有挂)-哔哩哔哩1、这是跨...
透视挂!wepoker免费脚本... 透视挂!wepoker免费脚本,wepoker有什么规律,策略教程(一直真的是有挂)-哔哩哔哩wep...
透视测试!pokermaste... 透视测试!pokermaster脚本(透视)开挂辅助软件(确实有挂)-哔哩哔哩1、完成pokerma...
透视系统!破解辅助插件wepo... 您好,破解辅助插件wepoker这款游戏可以开挂的,确实是有挂的,需要了解加去威信【48527505...