天天看點

js Proxy in Action

js Proxy in Action

js Proxy in Action

攔截 vue data 對象
js Proxy in Action
const target = {
  msg1: "hello",
  msg2: "everyone",
};

const handler = {
  get: function(target, prop, receiver) {
    console.log('target, prop, receive', target, prop, receiver);
    return "world";
  }
};

const proxy = new Proxy(target, handler);

console.log(proxy.msg1);
// world
console.log(proxy.msg2);
// world

      

繼續閱讀