JS代理Proxy對象的使用html
<div id="person"></div> <script> const person = { name: "Tom", }; // 設置值的時候,界面顯示也隨之變化 const handler = { set: function (obj, prop, value) { obj[prop] = value; document.getElementById("person").innerText = value; }, }; const personProxy = new Proxy(person, handler); </script>