16 lines
291 B
JavaScript
16 lines
291 B
JavaScript
function bindDataToElement(data) {
|
|
const proxy = new Proxy(data, {
|
|
set(target, key, value) {
|
|
target[key] = value;
|
|
return true;
|
|
},
|
|
});
|
|
|
|
console.log("proxy", proxy);
|
|
}
|
|
|
|
window.onload = () => {
|
|
const data = { name: "张三", age: 20 };
|
|
bindDataToElement(data);
|
|
};
|