简体   繁体   English

带有ES6和Promises的Angular 2在Internet Explorer 11上不起作用

[英]Angular 2 with ES6 and Promises not working on Internet Explorer 11

I have an Angular 2 app running fine on Chrome / Edge but it fails on Internet Explorer with the following error. 我有一个在Chrome / Edge上正常运行的Angular 2应用,但在Internet Explorer上失败,并出现以下错误。

在此处输入图片说明

I am using the following index.html: 我正在使用以下index.html:

<!DOCTYPE html>
<html>
<head>
    <base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>My App</title>

    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/lightbox.css">
    <link rel="stylesheet" href="css/site.css">

    <script src="scripts/es6-shim/es6-shim.min.js"></script>
    <script src="scripts/systemjs/system-polyfills.js"></script>
    <script src="scripts/angular2/shims_for_IE.js"></script>
    <script src="scripts/jquery/jquery.min.js"></script>
    <script src="scripts/bootstrap/bootstrap.min.js"></script>
    <script src="scripts/systemjs/system.js"></script>
    <script src="scripts/angular2/angular2-polyfills.min.js"></script>
    <script src="scripts/angular2/angular2.min.js"></script>
    <script src="scripts/angular2/http.min.js"></script>
    <script src="scripts/angular2/router.min.js"></script>
    <script src="scripts/angular2/Rx.min.js"></script>
    <script src="scripts/moment/moment-with-locales.min.js"></script>
    <script src="scripts/lightbox/lightbox.js"></script>
    <script src="scripts/html5sql/html5sql.min.js"></script>

    <script>
        System.config({
            packages: { 'app': { defaultExtension: 'js' } }
        });
        System.import('app/app/app.component');
    </script>
</head>
<body>
    <app></app>
</body>
</html>

The top 3 shims/polyfills should fix any missing functionality for IE as far as I can find. 据我所知,前3个垫片/填充物应该修复IE缺少的任何功能。 I'm not sure if it's the lack of native Internet Explorer support for Promises, ES6 or something else. 我不确定是否缺少对Promises,ES6或其他内容的本地Internet Explorer支持。 I tried swapping all Promises to Observables but still the error remains. 我尝试将所有Promises交换为Observables,但仍然存在错误。

For anyone interested, the solution was mainly to change my TypeScript output to ES5 instead of ES6. 对于任何感兴趣的人,解决方案主要是将我的TypeScript输出更改为ES5而不是ES6。 Even though I was using various ES6 shims, this still wasn't enough for Internet Explorer to work. 即使我正在使用各种ES6垫片,但这仍不足以使Internet Explorer正常工作。

UPDATE: 更新:

Changing the TypeScript compiler output to ES5 was done in the tsconfig.json file: tsconfig.json文件中将TypeScript编译器输出更改为ES5:

{
  "compilerOptions": {
    "target": "es5"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM