标签: javascript node.js mean-stack
const EventEmitter = require('event'); const emitter = new EventEmitter();
//注册一个收听者
emitter.on('messageLogged', function() { console.log("listen is called "); });
//发起活动
emitter.emit('messageLogged');
答案 0 :(得分:1)
尝试要求带有s的“事件”
const EventEmitter = require('events');
https://nodejs.org/api/events.html