Object.defineProperty()
2020-05-25 本文已影响0人
Invictus_2635
const object1 = {};
Object.defineProperty(object1, 'property1', {
value: 42, //值
writable: false,
get(){}, //当被访问时 触发
set(){}, //当被修改时 触发
});
const object1 = {};
Object.defineProperty(object1, 'property1', {
value: 42, //值
writable: false,
get(){}, //当被访问时 触发
set(){}, //当被修改时 触发
});