Tôi không thể hiểu tại sao tôi không thể làm cho máy chủ của tôi chạy chức năng phát ra.Sử dụng chức năng phát ra trong node.js
Dưới đây là mã của tôi:
myServer.prototype = new events.EventEmitter;
function myServer(map, port, server) {
...
this.start = function() {
console.log("here");
this.server.listen(port, function() {
console.log(counterLock);
console.log("here-2");
this.emit('start');
this.isStarted = true;
});
}
listener HERE...
}
Người nghe là:
this.on('start',function(){
console.log("wtf");
});
Tất cả các loại console là thế này:
here
here-2
Bất cứ ý tưởng tại sao nó sẽ không in 'wtf'
?
Cảm ơn nhiều!!! – Itzik984