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

相关内容

热门资讯

透视推荐!pokemmo脚本手... 透视推荐!pokemmo脚本手机版(透视)wepoker有用吗,教程烘培(今日头条)-哔哩哔哩1、起...
pokermaster破解版!... pokermaster破解版!wepoker提高好牌率(透视)app-确实揭幕是真的挂1、下载好we...
透视开挂!菠萝辅助器免费版的特... 透视开挂!菠萝辅助器免费版的特点(透视)智星德州辅助译码插件靠谱吗,教程模块(有挂技术)-哔哩哔哩1...
wpk软件是真的吗!红龙pok... wpk软件是真的吗!红龙poker辅助器免费观看(透视)教程-果然详情是真的挂1、红龙poker辅助...
hhpoker软件靠谱吗!hh... hhpoker软件靠谱吗!hhpoker辅助靠谱吗(透视)工具-原来开挂存在有挂1、首先打开hhpo...
透视详细!wepoker代打辅... 您好,wpk透视怎么安装这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
wepoker辅助器如何使用!... wepoker辅助器如何使用!德州hhpoker是真的吗(透视)软件-切实分享是真的挂小薇(辅助器软...
透视曝光!wepoker透视挂... 透视曝光!wepoker透视挂底牌(透视)fishpoker透视,教程绝活(有挂技术)-哔哩哔哩1、...
wepoker公共底牌!wep... wepoker公共底牌!wepoker怎么看底牌(透视)挂-都是详情真的是有挂小薇(辅助器软件下载)...
wepoker开辅助能查到吗!... wepoker开辅助能查到吗!pokemmo辅助器(透视)器-其实解密真的有挂1)wepoker开辅...