简体   繁体   English

Pace.js无法在IE 11中运行

[英]Pace.js not working in IE 11

I have an angular-cli project. 我有一个angular-cli项目。 I have also added pace. 我也加快了步伐。 I added it inside the header in index.html <script src="assets/lib/pace/pace.min.js"></script> . 我在index.html <script src="assets/lib/pace/pace.min.js"></script>的标题中添加了它。 It works correctly in chrome, but in IE-11 I get the following error: 它在chrome中正常工作,但在IE-11中我收到以下错误:

ERROR TypeError: Invalid calling object
      stack: "TypeError: Invalid calling object
   at scheduleTask (http://localhost:4200/polyfills.bundle.js:8607:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6279:21)
   at DELEGATE_ZS.onScheduleTask (http://localhost:4200/polyfills.bundle.js:6169:13)
   at ZoneDelegate.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6273:17)
   at Zone.prototype.scheduleTask (http://localhost:4200/polyfills.bundle.js:6104:17)
   at Zone.prototype.scheduleMacroTask (http://localhost:4200/polyfills.bundle.js:6127:13)
   at Anonymous function (http://localhost:4200/polyfills.bundle.js:8637:17)
   at proto[name] (http://localhost:4200/polyfills.bundle.js:7142:17)
   at Anonymous function (http://localhost:4200/vendor.bundle.js:63666:13)
   at Observable.prototype._trySubscribe (http://localhost:4200/vendor.bundle.js:4172:13)",
      Symbol(observable)_h.fo48yw1o6i8: undefined,
      Symbol(rxSubscriber)_g.fo48yw1o6i8: undefined

What am I doing wrong? 我究竟做错了什么?

There is a conflict between pace and the changes in zone.js v0.8.12 - see below for details. 在pace.js v0.8.12中,节奏和更改之间存在冲突 - 有关详细信息,请参见下文。 To fix the issue I made sure to load pace.min.js after zone.min.js and the other IE polyfills and it worked like a charm. 为了解决这个问题,我确保在zone.min.js和其他IE polyfill之后加载pace.min.js,它就像一个魅力。

https://github.com/HubSpot/pace/issues/399 https://github.com/HubSpot/pace/issues/399

In the newest version of zone.js (0.8.12) using pace with it causes all XMLHttpRequests to fail with the error message:

TypeError: Unable to get property 'apply' of undefined or null reference
Please see my issue for more information. If I get time I'll try and fix the issue inside pace itself but I've already spent the good part of 3-4 hours trying to debug this issue so we'll see..

https://github.com/angular/zone.js/issues/816 https://github.com/angular/zone.js/issues/816

After updating zone.js to the latest version (0.8.12) we started getting errors when loading an Angular page with angular/http calls in Internet Explorer 11 (works fine in Chrome). The request never initiates and there are a few errors in the console:

Unhandled Promise rejection: Unable to get property 'apply' of undefined or null reference ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Unable to get property 'apply' of undefined or null reference TypeError: Unable to get property 'apply' of undefined or null reference
at scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142795:13)
at ZoneDelegate.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140947:21)
at Zone.prototype.scheduleTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140772:17)
at Zone.prototype.scheduleMacroTask (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:140795:13)
at Anonymous function (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZihM_8:142824:17)
at proto[name] (https://localhost:44334/dist/vendor.js?v=OQlIcABpA29sHMIhDRnH-EBWeJs6_U6bx7vEgZ
After digging around a bit, it looks like a very new bit of code could be causing this, introduced in PR #800

The exact line of failure is below, where oriAddListener is undefined, causing the above error :

oriAddListener.apply(data.target, ['readystatechange', newListener]); // line 110
Rolling zone.js back to 0.8.11 which was before that PR fixes the issue and works as expected.

As suggested by @Dovev Hefetz and discussed in this git thread, it seems to be confirmed that the order of scripts loading affects IE behavior in this situation. 正如@Dovev Hefetz所建议并在这个git线程中讨论的那样,似乎可以确认脚本加载的顺序会影响这种情况下的IE行为。 For those not sure how to make pace.min.js load after the main scripts in angular, follow these easy steps. 对于那些不确定如何在角度主要脚本之后加载pace.min.js的人,请按照这些简单的步骤操作。

  • Make sure to change zone.js in your package.json to "zone.js": "~0.8.11" 确保将package.json中的"zone.js": "~0.8.11"更改为"zone.js": "~0.8.11"

OR 要么

  • Remove the individual imports from your index.html : index.html中删除单个导入:

    <script src="/pace/pace.js"></script> <link href="/pace/themes/pace-theme-barber-shop.css" rel="stylesheet" />

  • In your angular(-cli).json : 在你的angular(-cli).json中

    1. Include pace-theme .css in the styles 样式中包含pace-theme .css

    "styles": [ "src/assets/plugins/pace/pace-theme-flash.css", "src/styles.scss" ],

    1. Include pace.min.js in the scripts 在脚本中包含pace.min.js

    "scripts": [ "src/assets/plugins/pace/pace.min.js" ]

  • That's it! 而已! This should ensure that pace is loaded after zone.js 这将确保步伐 zone.js后装

Bonus: Angular supports modern browsers and Internet Explorer. 奖励: Angular支持现代浏览器和Internet Explorer。 To make the most of the features it offers, your project needs additional small tweaks to support some libraries. 为了充分利用它提供的功能,您的项目需要额外的小调整来支持一些库。 A good place to start is to check this great post . 一个好的开始是检查这篇伟大的帖子

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

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