const target = { message : 'Hello, world!' , }; const handler = { get : function ( target, property ) { if (property in target) { return target[property]; } return ` 属性${property}不存在。` ; } , }; const proxy = new Proxy (target, handler); console.log (proxy.message ) ; // Hello, world! console.log ( proxy.nonExistentProperty ); // 属性 nonExistentProperty 不存在。