简体   繁体   English

iOS 6 javascript与object.defineProperty的间歇性问题

[英]iOS 6 javascript intermittent issues with object.defineProperty

Has anyone else noticed intermittent errors/issues in the new iOS 6 javascript engine when accessing properties on objects where the property was defined using newer Object.defineProperty syntax? 当访问使用较新的Object.defineProperty语法定义属性的对象的属性时,有没有其他人注意到新iOS 6 javascript引擎中的间歇性错误/问题?

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty

I'm seeing occasions where the javascript will fail stating undefined is not a function on methods of objects accessied as properties on objects defined in this manner. 我正在看到javascript失败的情况,说明undefined不是作为以这种方式定义的对象上的属性访问的对象的方法的函数。

According to Kangax's ES5 table , "In some versions of WebKit Object.defineProperty does not work with DOM objects." 根据Kangax的ES5表 ,“在某些版本的WebKit中,Object.defineProperty不能与DOM对象一起使用。” I'm assuming this is what you may be referring to. 我假设这是你可能指的。 It's note #2 at the bottom of the page. 注意页面底部的#2。 Hope this helps! 希望这可以帮助!

In case you haven't already solved this, make sure the said property is enumerable (and if necessary configurable)... 如果您尚未解决此问题,请确保所述属性是可枚举的(如果必要,可以配置)...

Object.defineProperty(obj, "key", {
  enumerable: true,
  configurable: true
});

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

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