我想关注对象的变化,但是代理对象似乎是代理服务器对象。
我做了什么来测试这个功能:
var myObject = {},
watchDog = new Proxy( myObject, {
set: function (target, key, value)
{
console.log(key, 'changed to ', value );
target[key] = value;
}
});
myObject.test = 1;
它永远不会被触发,因为它似乎不是对象代理。当我倒东西的时候(
console.log( watchDog );
)在代理对象中,它显示了大量的内容,如下所示:
.............
.............
.............
{ http_parser: '2.8.0',
node: '8.11.3',
v8: '6.2.414.54',
uv: '1.19.1',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
nghttp2: '1.32.0',
napi: '3',
openssl: '1.0.2o',
icu: '60.1',
unicode: '10.0',
cldr: '32.0',
tz: '2017c' },
arch: 'ia32',
platform: 'win32',
release:
{ name: 'node',
lts: 'Carbon',
sourceUrl: 'https://nodejs.org/download/release/v8.11.3/node-v8.11.3.tar
gz',
headersUrl: 'https://nodejs.org/download/release/v8.11.3/node-v8.11.3-he
ders.tar.gz',
libUrl: 'https://nodejs.org/download/release/v8.11.3/win-x86/node.lib' }
argv:
[ 'F:\\Program Files (x86)\\nodejs\\node.exe',
'L:\\Utils\\codebeat\\SerialInputDevice\\server\\app.js' ],
execArgv: [],
env:
{ ALLUSERSPROFILE: 'C:\\ProgramData',
APPDATA: 'C:\\Users\\User\\AppData\\Roaming',
CLASSPATH: '.;C:\\Program Files (x86)\\Java\\jre7_32\\lib\\ext\\QTJava.z
p',
CommonProgramFiles: 'C:\\Program Files (x86)\\Common Files',
'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files',
CommonProgramW6432: 'C:\\Program Files\\Common Files',
..............
..............
etc.
所以这不是一个对象代理。如何创建对象代理而不是代理服务器对象?