多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
![](https://box.kancloud.cn/758eb754dd7305680e6214a113b7905d_511x224.png) ![](https://box.kancloud.cn/6f1d267c076a2780577b438d8b14095a_774x195.png) ~~~ // 明星 let star = { name: '张XX', age: 25, phone: '13910733521' } // 经纪人 let agent = new Proxy(star, { get: function (target, key) { if (key === 'phone') { // 返回经纪人自己的手机号 return '18611112222' } if (key === 'price') { // 明星不报价,经纪人报价 return 120000 } return target[key] }, set: function (target, key, val) { if (key === 'customPrice') { if (val < 100000) { // 最低 10w throw new Error('价格太低') } else { target[key] = val return true } } } }) // 主办方 console.log(agent.name) console.log(agent.age) console.log(agent.phone) console.log(agent.price) ~~~ ![](https://img.kancloud.cn/9f/94/9f94a37c7b292aca98438431b9f21c57_318x106.png) ~~~ // 想自己提供报价(砍价,或者高价争抢) agent.customPrice = 150000 // agent.customPrice = 90000 // 报错:价格太低 console.log('customPrice', agent.customPrice) ~~~ ![](https://box.kancloud.cn/4b675b34df8b48774057b5f37e9c8a41_622x423.png) ![](https://box.kancloud.cn/1abffccc606547c2f04b237e6b7aec7b_451x92.png) ![](https://box.kancloud.cn/1663816354123b53db86e8bf5974d304_760x370.png) ![](https://box.kancloud.cn/36d8e8630250b6b006160d388a1e969b_546x164.png) ![](https://box.kancloud.cn/9150feb37bb8b10298cd4574e5131e13_514x140.png) ![](https://box.kancloud.cn/89501ffa172378d94f22ad4b092ce18c_573x123.png) ![](https://img.kancloud.cn/f5/6f/f56feea199e871ca71bc57f1231ad5f4_780x288.png) ![](https://img.kancloud.cn/0e/d0/0ed0ac90949256fe5e1c7ed7d416ef89_753x299.png)