Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.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
相当于jquery';node.js EventEmitter的s event.type?_Jquery_Node.js - Fatal编程技术网

相当于jquery';node.js EventEmitter的s event.type?

相当于jquery';node.js EventEmitter的s event.type?,jquery,node.js,Jquery,Node.js,node.js是否具有jquery的event.type方法的等价物,即以字符串形式给出事件名称的方法 我已经尝试过event.type,但到目前为止它对我不起作用…您可以添加一个小包装器函数来命名它 EventEmitter.prototype.addNamedListener = function(event, handler){ return this.addHandler(function(x){ handler({ event: event, data

node.js是否具有jquery的event.type方法的等价物,即以字符串形式给出事件名称的方法


我已经尝试过event.type,但到目前为止它对我不起作用…

您可以添加一个小包装器函数来命名它

 EventEmitter.prototype.addNamedListener = function(event, handler){
      return this.addHandler(function(x){
          handler({ event: event, data: x });
      });
 };

您使用哪个库来处理事件?Node.js没有DOM,因此没有现成的事件。我的意思是,我使用Node.js eventemitter类签出自己创建的事件,看起来它将
this.event
添加到提供该信息的处理程序中。(特别是因为它有通配符和名称空间事件)谢谢@dominic我在github上看到了这一点,但因为我只是想找一个小技巧来节省20行代码,我不想再增加500行来让它工作;)Event.type是因为Dom。EventEmitter更像是赤裸裸的骨骼。