我读到 nowjs 支持传递对象以及字符串,但由于某种原因,我遇到了问题。这是他们网页中的 nowjs 示例,只有一个字符串被解析并且对我来说工作正常,
客户端
now.test('foo', function(msg){
console.log(msg);
});
服务器端
everyone.now.test = function(val, callback){
callback(val + ' bar!');
}
下面的代码我尝试传递并反对 val ,
客户端
now.test('default', function(msg){
console.log(Object.keys(msg));
console.log(msg.GetEthernet());
});
服务器端
everyone.now.test = function(val, callback){
var profile = honeydConfig.GetProfile(val);
console.log("Got eth " + profile.GetEthernet() + " for profile " + profileName);
callback(profile);
}
在服务器端,它打印 GetEthernet 函数的正确输出。在客户端,它只是说,“未捕获的 TypeError:Object # has no method 'GetEthernet'”并为 Object.keys 返回一个空数组。