【问题标题】:Angular 1.4.8 incompatible with IE11 - Object doesn't support property or method 'endsWith'Angular 1.4.8 与 IE11 不兼容 - 对象不支持属性或方法“endsWith”
【发布时间】:2017-07-11 03:57:41
【问题描述】:

如何使用 HAndsOnTable 和 Angular 1.4.8 让这个 JSFiddle 与 IE11 一起使用?我收到此错误:

对象不支持属性或方法'endsWith'

我不确定,但我认为罪魁祸首是这一行:

$scope.$apply();

【问题讨论】:

  • 它根本不工作,这取决于您使用的浏览器。请修正您的 JavaScript 错误。
  • 它适用于最新的 chrome。我想知道为什么它在 IE 中不起作用。
  • 不,你的小提琴不起作用。它充满了错误。例如Error: [ng:areq] Argument 'TodoCtrl' is not a function, got undefined。或Mixed Content: The page at 'https://jsfiddle.net/r0pk793e/12/' was loaded over HTTPS, but requested an insecure stylesheet 'http://twitter.github.io/bootstrap/assets/css/bootstrap.css'. This request has been blocked; the content must be served over HTTPS.
  • 我可以确认,我使用的是最新版本的 Chrome,并且您的代码引发了大量错误。
  • 感谢 m8,现在我可以解决您的 IE11 问题了!干杯

标签: angularjs internet-explorer-11 handsontable


【解决方案1】:

我修复了您的fiddle,还修复了 IE11 错误。请注意 .endWith() 在 IE 中不是有效的函数。一旦你添加了这个函数作为原型,你就可以了:

if (!String.prototype.endsWith) {
  String.prototype.endsWith = function(searchString, position) {
      var subjectString = this.toString();
      if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
        position = subjectString.length;
      }
      position -= searchString.length;
      var lastIndex = subjectString.indexOf(searchString, position);
      return lastIndex !== -1 && lastIndex === position;
  };
}

(取自https://www.sitepoint.com/community/t/endswith-issue-in-ie11/233838

【讨论】:

  • 谢谢!奇怪的是,当我将您的prototype.endsWith 添加到我的小提琴时它工作得很好,但是在您的...当我更改表中的值时,页脚不会更新。
  • 我会检查这个。待命
猜你喜欢
  • 2017-06-27
  • 2016-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-17
  • 1970-01-01
  • 1970-01-01
  • 2015-03-31
相关资源
最近更新 更多