【问题标题】:Angular 2+: Internet Explorer: Unable to get property 'call' of undefined or null referenceAngular 2+:Internet Explorer:无法获取未定义或空引用的属性“调用”
【发布时间】:2017-11-15 19:08:46
【问题描述】:

在 Angular 4.2.4 (Angular-CLI 1.1.3)、IE11 中,我得到 SCRIPT1002: Syntax errorSCRIPT5007: Unable to get property 'call' of undefined or null reference。我有我的 polyfills,我会假设 Webpack 和 Angular-CLI 会完成其余的工作。我在这里错过了什么?

Unable to get property 'call' of undefined or null reference 在它后面说:bootstrap 50034e0a1f93dabcb117 (54, 1) 没有指明真实文件名。 Syntax error 说它在 vendor.bundle.js (63117,26) 中,看起来像:

window.setTimeout(() => {
    window.removeEventListener('click', suppressClick, true);
}, 0);

更新:以前对我来说应该更明显,但这看起来像 ES6 代码,它应该编译到 ES5。

【问题讨论】:

  • 您遇到语法错误和未定义的变量,但未共享任何代码。
  • 嗨 BBaysinger,我遇到了同样的错误,尝试删除 package.lock.json 和 npm install againg,对我有用
  • 您是否使用“ng serve”启动您的应用程序?你在使用任何 JQuery 代码吗?
  • 这可能是一百个问题之一。你可能想分享一个 git repo,因为这是一个广泛的问题。正如@AmericoArvani 提到的,这可能与您的 npm 安装或软件包有关。
  • 它是否在其他浏览器中工作?

标签: javascript angular typescript webpack angular-cli


【解决方案1】:

这里可能有很多问题,正如 cmets 中提到的,但我最近遇到了浏览器兼容性问题,解决方案是使用 polyfills。取消注释以下行:

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

然后运行您的应用程序。它应该工作到IE10,至少它对我们有用。根据错误消息,它也可能对您有用。

【讨论】:

【解决方案2】:

尝试从资产中加载 jQuery polyfills

在 index.html 的头部:

  <script src="assets/...">

我的看法是至少尝试https://plugins.jquery.com/webshims/

【讨论】:

    【解决方案3】:

    对于仍然遇到此问题的任何人,请尝试以下操作:

    Angular 2+: IE 11 Unable to get property 'call' of undefined or null reference

    如果您遇到的错误发生在如下所示的一大块代码中:

    window.setTimeout(() => {
        window.removeEventListener('click', suppressClick, true);
    }, 0);
    

    ...那么请让我知道解决方案是否有效。我将更新此答案,并可能将此问题标记为重复。

    目前我认为这些问题不是同一个问题,因为bundle.js 中的不同代码会出现错误。有人否决了这个答案,但没有就这些问题是否有相同的解决方案提供任何反馈。

    我目前没有办法对此进行测试,但想指导人们找到一个可能的解决方案。

    【讨论】:

      猜你喜欢
      • 2018-09-29
      • 2016-05-20
      • 2017-07-05
      • 2020-06-02
      • 1970-01-01
      • 2019-05-13
      • 2019-03-04
      • 2017-07-25
      • 2014-08-01
      相关资源
      最近更新 更多