未捕获的TypeError:对象#<error>没有方法

Est*_*ban 1 javascript jquery jquery-chosen

将Web应用程序部署到远程主机后,我收到了这个奇怪的错误.

Uncaught TypeError: Object #<error> has no method 'endsWith'

事实:

  • 该应用程序在我的本地计算机上作为主机完美运行.
  • 当部署到远程主机中的IIS时,应用程序会抛出此错误.
  • 应用程序加载的文件在两种情况下都相同.

加载的文件是:

在此输入图像描述

文件编写如下:

在此输入图像描述

方法是这些:

String.prototype.startsWith = function (toMatch) {
    var self = this;
    return self.indexOf(toMatch) == 0;
};

String.prototype.endsWith = function (toMatch) {
    var self = this;
    return self.toLowerCase().indexOf(toMatch.toLowerCase(), 
        self.length - toMatch.length) !== -1;
};

String.prototype.contains = function (toMatch) {
    var self = this;
    return self.indexOf(toMatch) !== -1;
};
Run Code Online (Sandbox Code Playgroud)

我不是使用javascript的高手但是当我访问原型对象时,intellisense向我显示了这个:

在此输入图像描述

Ber*_*rgi 5

此异常有两个可能的原因:

  • 原型扩展脚本尚未加载(特别是在部署时可能会发生变化,在不小心加载异步时),未正确执行或其后的方法delete(不太可能)
  • 或者说神秘Object #<error>不是String实例.看起来如果那是问题:-)