let obj = {
name: 'jack',
arr: [1, 3, 2]
}
let pro = new Proxy(obj, {
get(target, key) {
if (key === 'arr') {
return target[key] = target[key].sort()
}
}
})
console.log(obj.arr, '源数据1') //1 3 2
console.log(pro.arr, '代理数据')//1 2 3
console.log(obj.arr, '源数据2') //1 2 3