简体   繁体   English

apply()不适用于Node.js eventemitter的emit()函数

[英]apply() does not work on Node.js eventemitter's emit() function

The apply() method does not work on Node's eventemitter's emit function. apply()方法不适用于Node的eventemitter的emit函数。

I execute these 2 statements: 我执行这两个语句:

this._baseEmitter.emit('activity', {test: 'zever1'});

this._baseEmitter.emit.apply(this, ['activity', {test: 'zever2'}]);

The first 1 runs fine, and the event is captured by my listener. 第一个运行良好,事件由我的听众捕获。

The second one, however, does absolutely nothing. 然而,第二个绝对没有。

Does anyone know why? 有谁知道为什么? Is the emit() function perhaps missing the apply method? emit()函数可能缺少apply方法吗? If so, I would think I would receive some error messages, but that's not the case either. 如果是这样,我会认为我会收到一些错误消息,但事实并非如此。

第一个参数不应该是this._baseEmitter吗?

this._baseEmitter.emit.apply(this._baseEmitter, ['activity', {test: 'zever2'}]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM