Javascript Internet Explorer中未打开Angular 8应用程序

Javascript Internet Explorer中未打开Angular 8应用程序,javascript,angular,typescript,internet-explorer-11,angular8,Javascript,Angular,Typescript,Internet Explorer 11,Angular8,我不熟悉Angular 8,目前正在开发一个web应用程序。它在googlechrome和EDGE中运行良好,但在ie11中甚至没有加载。我通过互联网探索解决方案,并尝试了一些建议的解决方案 我尝试的是: 尝试01: 在index.html <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <script src="https://npmcdn.com/angular2/es6/dev/src/testing/s

我不熟悉Angular 8,目前正在开发一个
web应用程序。它在
googlechrome
EDGE
中运行良好,但在
ie11
中甚至没有加载。我通过互联网探索解决方案,并尝试了一些建议的解决方案

我尝试的是:


尝试01:

index.html

<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
<script src="https://npmcdn.com/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
尝试03

浏览器列表
文件中包括对
IE 9-11
的支持



但这一切都是徒劳的,我无法解决这个问题有人能找出我做错了什么吗

默认情况下,在angular version 8中,启用了
ng build
的差异加载。但是对于
ng test
ng serve
,它只生成一个ES2015版本,不能在IE11中运行

有两种方法可以在发球时使用ES5代码,使angular 8应用程序在IE11中工作

  • 完全禁用差异加载。(不推荐使用

    您可以通过在tsconfig.json中将目标从“es2015”更改为“es5”来关闭差异加载

  • 有多种服务配置

    在tsconfig.app.json旁边创建一个新的tsconfig-tsconfig-es5.app.json,内容如下:

    { 
     "extends": "./tsconfig.app.json",
     "compilerOptions": { 
     "target": "es5"   
      }
    }
    
    在angular.json中,在构建和服务目标下添加两个新的配置部分(es5节点),以提供新的tsconfig

    "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": "<your application name>:build:es5"
    }
    }
    },
    
    然后,您可以使用以下命令使用此配置运行服务:

    ng serve --configuration es5
    

  • 清除ie浏览器缓存并重试。我已经尝试过了。甚至我也停止了缓存,但它不起作用。您是否尝试过将
    tsconfig.json
    中的目标从
    es2015
    更改为
    es5
    ?关于如何处理这些问题,有几种答案,例如:在尝试1中,您是否尝试从content=“IE=edge”更改为content=“IE=11”?@Arikael我在某个地方读到,如果您在
    angular 8
    工作,这不是一个好的解决方案。
    > 0.5%
    last 2 versions
    Firefox ESR
    not dead
    IE 9-11 # For IE 9-11 support, remove 'not'.
    
    ng serve --configuration es5