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中正常运行了。

相关内容

热门资讯

四分钟辅助!德普之星app安卓... 四分钟辅助!德普之星app安卓版破解版,wepokerplus脚本,项目教程(有挂辅助)1、玩家可以...
2分钟辅助!hhpoker透视... 2分钟辅助!hhpoker透视脚本,wepoker有透视吗,教程书教程(有挂头条)1、超多福利:超高...
第七分钟辅助!wepoker透... 第七分钟辅助!wepoker透视app下载,aa poker辅助包,讲义教程(有挂分享)一、wepo...
第八分钟辅助!wepoker怎... 第八分钟辅助!wepoker怎么开辅助,xpoker辅助器,模块教程(的确有挂)1、不需要AI权限,...
一分钟辅助!wepoker有没... 一分钟辅助!wepoker有没有挂,pokemmo脚本辅助器,讲义教程(有挂教学)1、完成pokem...
第一分钟辅助!hhpoker是... 第一分钟辅助!hhpoker是真的还是假的,wepoker辅助器,阶段教程(有挂技巧)1、金币登录送...
8分钟辅助!hhpoker辅助... 8分钟辅助!hhpoker辅助挂,wejoker私人辅助软件,窍要教程(有挂分析)1、玩家可以在we...
第6分钟辅助!xpoker透视... 第6分钟辅助!xpoker透视辅助,wejoker内置辅助,窍门教程(有挂秘诀)该软件可以轻松地帮助...
第六分钟辅助!aapoker公... 第六分钟辅助!aapoker公共底牌,aapoker怎么设置抽水,办法教程(真是有挂)1、在aapo...
9分钟辅助!wepoker辅助... 9分钟辅助!wepoker辅助真的假的,aapoker透视脚本下载,手册教程(有挂解密)1、首先打开...