mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-14 12:14:40 +01:00
24 lines
355 B
JavaScript
24 lines
355 B
JavaScript
const data = {
|
|
hello: {
|
|
log() {
|
|
return 'hello log';
|
|
},
|
|
},
|
|
hi: {
|
|
log() {
|
|
return 'hi log'
|
|
},
|
|
},
|
|
}
|
|
|
|
const blankObject = {};
|
|
|
|
const proxy = new Proxy(blankObject, {
|
|
get(target, key) {
|
|
if (key in data) return data[key]; // <---
|
|
return target[key]; // default
|
|
}
|
|
});
|
|
|
|
console.log(proxy.hello.log()); // hello log;
|