js 监听 变量变化
var o = {};
setTimeout(function () {
o.abb = '2';
}, 4000);
Object.defineProperties(o, {
abb: {
configurable: true,
set: function (newValue) {
var abb = newValue;
console.log('你修改了 abb 的值:' + abb);
}
}
});
var o = {};
setTimeout(function () {
o.abb = '2';
}, 4000);
Object.defineProperties(o, {
abb: {
configurable: true,
set: function (newValue) {
var abb = newValue;
console.log('你修改了 abb 的值:' + abb);
}
}
});