- jQuery.proxy
- ES6的proxy
- DOM事件代理
举个例子:
let start = {
name: 'xxx',
age: 18,
phone: 12212212122
}
let agent = new Proxy(stat, {
get: function(target, key) {
if (key === 'phone') {
return 'anent_phone: 13313313133'
}
if (key === 'price') {
return 120000
}
return target[key]
}
set: function(target, key, value) {
// 自定义逻辑来设置value
}
})