Angular2:Object不支持Microsoft Edge浏览器中的此操作

时间:2017-12-27 13:47:06

标签: javascript angular promise microsoft-edge angular-promise

我的angular2应用程序仅在Microsoft边缘引发异常声明对象不支持此操作。请查看下图:

enter image description here

enter image description here

我调试并发现异常是在promise然后代码抛出的。更具体地说,我在下面的代码中得到错误:

this.dataLayerService
            .postLogin(this.model, this.postURL)
            .then(usermasterResponse => this.setToken(usermasterResponse))
            .catch(error => {
                  this.toastCommunicationService.setMessage(error, "",
                    this.toastCommunicationService.errorType)
            });

我还在index.html文件中添加了以下脚本,但这也是徒劳的。

<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.1/es6-shim.js"></script>

任何帮助都将受到高度赞赏。

提前致谢。

3 个答案:

答案 0 :(得分:0)

<meta http-equiv="x-ua-compatible" content="ie=edge">放入index.html 并检查您的polyfills脚本并导入所有core-js / es6 / scripts

答案 1 :(得分:0)

在角度项目文件夹中找到您的polyfills.ts文件并导入以下行:

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es7/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/set';
import 'core-js/es7/array';

如果您使用网络动画,那么您需要:

/** IE10 and IE11 requires the following to support `@angular/animation`. */
import 'web-animations-js';  // Run `npm install --save web-animations-js`.

对于常青浏览器,您需要这样:

/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

常青浏览器定义(original):

Chrome,Firefox,Internet Explorer和Safari的最新版本是常青浏览器,即它们会自动更新,而不会提示用户。对于Internet Explorer,大多数人认为这意味着IE10 +。

答案 2 :(得分:0)

问题在于以下代码中的 EventSource

this.eventsource = new EventSource(this.configService.get("BaseURL"));

我通过添加Event Source Polyfill js解决了这个问题。我按照EventSource Polyfill链接安装了js。

感谢大家的帮助。

相关问题