Angular 8 + IE 11 Angular应用程序无法在IE 11上运行

时间:2020-02-20 15:50:30

标签: arrays angular internet-explorer build production

我正在使用angular8。我的应用程序已准备好进行生产,但不能在IE11上运行。所有其他浏览器都可以正常工作。在IE 11上,它会出现一个空白页面并出现一些错误。我已经通过一些网站做了以下工作。仍然无法使用:(。预先感谢您的帮助

第1步:

...
"target": "es5"

步骤2: 不是IE 9-10 IE 11

步骤3 更改polyfil.ts

“仍然无效”

3 个答案:

答案 0 :(得分:0)

我建议您开始使用IE进行调试。转到引发错误的单个文件。 通常,使用

会引发错误

=>

许多其他人也可以。因此,您需要将那些代码转换为更基本的代码。我转到代码转载的goto网站是:Babel。只是您需要将这些代码更改为转码。

希望有帮助。

答案 1 :(得分:0)

您需要按照以下步骤使Angular 8应用程序在IE 11中运行:

  1. tsconfig-es5.app.json旁边创建一个具有以下内容的新tsconfig tsconfig.app.json

    {
     "extends": "./tsconfig.app.json",
     "compilerOptions": {
         "target": "es5" 
      }
    }
    
  2. angular.json的{​​{1}}和build目标下添加两个新的配置部分,以提供新的tsconfig:

    serve
  3. 使用以下命令使用此配置运行服务:

    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
          ...
      },
      "configurations": {
        "production": {
            ...
        },
        "es5": {
          "tsConfig": "./tsconfig-es5.app.json"
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
          ...
      },
      "configurations": {
        "production": {
         ...
        },
        "es5": {
          "browserTarget": "yourAppName:build:es5"
        }
      }
    },
    

答案 2 :(得分:0)

  • 取消注释 polyfill.ts 文件中的一些导入。
  • 安装几个 npm 包。
  • 修改浏览器列表文件(使用 Angular 11 项目的浏览器列表文件)。

取消注释 \src\polyfills.ts 下的几行

// import 'classlist.js';  // Run `npm install --save classlist.js`.

// import 'web-animations-js';  // Run `npm install --save web-animations-js`.

安装几个 npm 包。

npm install --save classlist.js
npm install --save web-animations-js

修改浏览器列表文件。

搜索以下行。

not IE 9-11 # For IE 9-11 support, remove 'not'.

删除非关键字。

IE 9-11 # For IE 9-11 support, remove 'not'.

使用 Angular 11 browserslistrc 文件

not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

删除非关键字。

IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.