【问题标题】:SCRIPT438: Object doesn't support property or method 'filter' IE10SCRIPT438:对象不支持属性或方法“过滤器”IE10
【发布时间】:2014-03-12 23:47:04
【问题描述】:

我从网络服务加载一些数据并尝试过滤它。

var topLevelProductTypes = [];

topLevelProductTypes = productTypesArray.filter(function (pt) {
     return (pt.NS_designcentreproducttypeid.Id === null);
});

我收到错误 SCRIPT438:对象不支持属性或方法“过滤器”

【问题讨论】:

  • 您是否处于兼容模式? productTypesArray 真的是一个数组吗?
  • 此代码在 CRM 2011 内的 Web 资源上运行。我使用 crm 的 xrm 端点将 json 数据推送到 productTypesArray。
  • >> productTypesArray[0] { [prototype] : {...}, __metadata : {...}, NS_designcentreproducttypeid : {...}, NS_designcentretypeId : "558b2086-478e-e111- 8108-0050568d0006", NS_name : "1 Piece Enclosure (Shower)" } 添加到观看 >> productTypesArray[0].NS_designcentreproducttypeid.Id "15af4efc-468e-e111-8108-0050568d0006" >> productTypesArray[0].NS_designcentreproducttypeid { [原型]:{...},__metadata:{...},ID:“15af4efc-468e-e111-8108-0050568d0006”,逻辑名称:“ns_designcentretype”,名称:“阵雨”} 添加到观看

标签: javascript arrays html filter dynamics-crm-2011


【解决方案1】:

将此添加到您的标题中 <meta http-equiv="X-UA-Compatible" content="IE=edge" />

productTypesArray 在您的代码中看起来未声明。我假设它被分配给array

if( Object.prototype.toString.call( productTypesArray) === '[object Array]' ) {
    alert( 'It is an array' );
}

【讨论】:

  • 趣事:alert(Object.prototype.toString == toString);通常会保存一些击键或使用 ({}).toString 来确定。
  • 不要使用X-UA-Compatible。修复真正的错误——99% 的情况下 HTML 无效。
  • 我运行了该检查并收到警报,因此 productTypesArray 实际上是一个数组。
  • 相同的代码在我们的开发环境中运行,这是生产环境的克隆。
  • 是的,也没有修复它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-22
  • 2019-02-09
相关资源
最近更新 更多