const obj = {
a : 1,
b: 1,
c: { e : 1}
}
var proxy = new Proxy(obj,{
get(target,property, receiver) {
return Reflect.get(target, property, receiver);
},
set(obj, prop, value) {
return obj[prop] = value;
},
defineProperty(target, property: string, descriptor) {
return Reflect.defineProperty(target, property, descriptor);
},
})
export function proxyTest(){
proxy.a = 2;
}
当去掉set方法时,会执行defineProperty;但是当有set方法时,不会执行definePropery;这是为什么呢?
ABOUTYOU
相关分类