参考资料:https://zhuanlan.zhihu.com/p/75407419https://zhuanlan.zhihu.com/p/69106037
参考资料:
直接看一个例子:
1 2 3 4 5 6
let target = { x: 10, y: 20, }; let hanler = { get: (obj, prop) => 42 }; target = new Proxy(target, hanler); target.x; //42 target.y; //42