Open EdwardZZZ opened 7 years ago
const obj = {
a: 123,
b: {
c: 456
}
}
const newObj = new Proxy(obj, {
get(object, property) {
if (Reflect.has(object, property)) {
return Reflect.get(object, property);
}
console.log('unkown property', property);
}
});
console.log(newObj.a);
console.log(newObj.b);
console.log(newObj.b.c);
console.log(newObj.b.d);
1、将函数名做参数名传递到代理函数中,代理函数去判断函数是否存在
2、