Angular 6应用在IE和Edge中无法运行。
创始人
2024-10-16 10:00:49
0

要解决Angular 6应用在IE和Edge中无法运行的问题,可以尝试以下几个步骤:

  1. 确保你的Angular应用已经正确地被编译为ES5代码,因为IE和Edge不支持ES6及以上版本的JavaScript语法。在Angular中,你可以使用“target”选项来指定编译的目标版本。在tsconfig.json文件中,将"target"的值设置为"es5":
{
  "compilerOptions": {
    "target": "es5",
    ...
  },
  ...
}
  1. 确保你的Angular应用已经引入了所需的polyfills来填充IE和Edge缺少的功能。在src/polyfills.ts文件中,确保以下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';

/**
 * IE10 and IE11 requires the following for NgClass support on SVG elements
 */
import 'classlist.js';  // Run `npm install --save classlist.js`.

/**
 * IE10 and IE11 requires the following for the Reflect API.
 */
import 'core-js/es6/reflect';
  1. 如果你的Angular应用使用了一些ES6的新特性(如箭头函数、解构赋值等),可以引入额外的polyfills来填充这些新特性。在src/polyfills.ts文件中,将以下代码取消注释,并根据你的需要引入相应的polyfills:
/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import 'zone.js/dist/zone';  // Included with Angular CLI.

/***************************************************************************************************
 * APPLICATION IMPORTS
 */
import 'core-js/es7/reflect'; // Add this line to import the reflect-metadata module.

// Add more polyfills as needed, such as:
// import 'core-js/es6/array';
// import 'core-js/es6/string';
// import 'core-js/es6/map';
// import 'core-js/es6/set';
  1. 确保你的应用在index.html文件中正确地引入了所需的脚本文件。在index.html文件的标签中,确保以下脚本被引入:



  
  My App
  

  
  
  
  
  


  


请注意,你可以根据实际情况选择从本地文件引入polyfills,也可以使用CDN链接。

通过以上步骤,你的Angular 6应用应该可以在IE和Edge中正常运行了。

相关内容

热门资讯

玩家必看教程!德州局hhpok... 玩家必看教程!德州局hhpoker,WePoKer辅助器,黑科技教程(有挂透明)1、点击下载安装,微...
技巧知识分享!wepoker有... 您好,wepoker有没有透视方法这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302...
盘点十款!大菠萝辅助器,hhp... 自定义hhpoker辅助软件下载系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅...
最新通报!wepoker怎么设... 最新通报!wepoker怎么设置透视,德扑圈有透视吗,细节揭秘(有挂软件);实战中需综合运用上述技巧...
必看攻略!wpk辅助,wepo... 必看攻略!wpk辅助,wepoker辅助器下载,解说技巧(有挂辅助)是一款可以让一直输的玩家,快速成...
一分钟带你了解!aapoker... 一分钟带你了解!aapoker怎么拿好牌,aapoker辅助插件工具,线上教程(有挂透明)准备好在a...
我来分享!hhpoker可以控... 我来分享!hhpoker可以控制牌吗,德州局透视,辅助教程(有挂透视);大神普及一款德州ai内幕,确...
科技揭秘!约局吧app有挂吗,... 科技揭秘!约局吧app有挂吗,wepoker透视脚本网页,总结教程(有挂技巧);小薇(透视辅助)致您...
一起来讨论!hhpoker是正... 1、一起来讨论!hhpoker是正品吗,大菠萝免费辅助,wpk教程(有挂神器)。2、大菠萝免费辅助透...
推荐十款!aapoker发牌逻... 您好,佛手大菠萝有挂吗这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多玩家在...