Javascript 在Chrome-Jquery中使用访问器时出错
你能帮我解决Chrome给我带来的这个错误吗 它向我抛出的错误是->未捕获类型错误:不允许访问器属性Javascript 在Chrome-Jquery中使用访问器时出错,javascript,jquery,google-chrome,cookies,local-storage,Javascript,Jquery,Google Chrome,Cookies,Local Storage,你能帮我解决Chrome给我带来的这个错误吗 它向我抛出的错误是->未捕获类型错误:不允许访问器属性 *jquery-3.3.1.min.js:2 Uncaught TypeError: Accessor properties are not allowed. at Function.defineProperty (<anonymous>) at Storage.value (script.js:139) at HTMLDocument.<anonymous> (scri
*jquery-3.3.1.min.js:2 Uncaught TypeError: Accessor properties are not allowed.
at Function.defineProperty (<anonymous>)
at Storage.value (script.js:139)
at HTMLDocument.<anonymous> (script.js:91)
at l (jquery-3.3.1.min.js:2)
at c (jquery-3.3.1.min.js:2)*
在firefox/mozilla中,它不会向我抛出这个错误,而且我处理这些函数和访问器时没有问题!!!有人知道为什么会这样吗
谢谢你
// Functions
// object.watch
if (!Object.prototype.watch) {
Object.defineProperty(Object.prototype, "watch", {
enumerable: false
, configurable: true
, writable: false
, value: function (prop, handler) {
var
oldval = this[prop]
, newval = oldval
, getter = function () {
return newval;
}
, setter = function (val) {
oldval = newval;
return newval = handler.call(this, prop, oldval, val);
}
;
if (delete this[prop]) { // can't watch constants
Object.defineProperty(this, prop, {
get: getter
, set: setter
, enumerable: true
, configurable: true
});
}
}
});
}
// object.unwatch
if (!Object.prototype.unwatch) {
Object.defineProperty(Object.prototype, "unwatch", {
enumerable: false
, configurable: true
, writable: false
, value: function (prop) {
var val = this[prop];
delete this[prop]; // remove accessors
this[prop] = val;
}
});
}