から地図のプロキシを取得するとき、私は次のコードで立ち往生しています:互換性のない受信機ゲッター
class Infrastructure {
constructor() {
this._devices = new Map([
\t ['foo', 'bar']
])
}
get devices() {
return new Proxy(this._devices, {})
}
}
const infrastructure = new Infrastructure()
console.log(infrastructure.devices.get('foo'))
次のエラーで失敗します。
Method Map.prototype.get called on incompatible receiver
私はどこかに何かを縛る必要があることを知っていますが、私は一種の迷子であると認めなければなりません。
ありがとうございました!
それは私の* *のProxyクラスではありません@Sreekanth、それは[ES2015プロキシ](https://babeljs.io/docs/learn-es2015/#proxies) – Marvin
'インフラストラクチャです。 devices.get( 'foo') 'この返品は何を期待していますか? – Searching
'bar'を返します。 [地図](https://babeljs.io/docs/learn-es2015/#map-set-weak-map-weak-set)を参照してください。 – Marvin