Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在重写()nodejs上的socket.io中传递回调函数_Node.js - Fatal编程技术网

Node.js 在重写()nodejs上的socket.io中传递回调函数

Node.js 在重写()nodejs上的socket.io中传递回调函数,node.js,Node.js,我提到 Ganesh Kumar回答重写on(),但我无法将回调函数作为参数传递。为什么会这样?我不能在这个函数中传递回调函数吗 我的代码片段如下所示: socket.$emit = function(callback) { .... callback() } 它标记错误并将回调作为字符串处理。我做错什么了吗?在常规的emit函数中,不能传递回调 在重写版本中,您只能接受与常规版本相同的参数。因此,我无法使用回调吗?这是我的应用程序必须的。有人能推荐一些替代方案吗?

我提到 Ganesh Kumar回答重写on(),但我无法将回调函数作为参数传递。为什么会这样?我不能在这个函数中传递回调函数吗

我的代码片段如下所示:

socket.$emit = function(callback)
{
   ....
   callback()
}

它标记错误并将回调作为字符串处理。我做错什么了吗?

在常规的emit函数中,不能传递回调


在重写版本中,您只能接受与常规版本相同的参数。

因此,我无法使用回调吗?这是我的应用程序必须的。有人能推荐一些替代方案吗?