mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-01-26 09:50:31 +01:00
rewrite client
This commit is contained in:
23
test.js
Normal file
23
test.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user