【发布时间】:2016-08-09 06:42:01
【问题描述】:
我在我的 meteor.js 服务器上运行它:
Meteor.publish('games', function(){
this.onStop(function() {
Meteor.call('leaveQueue');
});
return Games.find({ player: this.userId })
});
当用户停止订阅时,它会调用 methods.js 上的这个函数:
Meteor.methods({
leaveQueue:function(){
console.log(this.userId);
}
});
它将 null 记录为 userId.. 现在,如果我在控制台上使用 Meteor.call('leaveQueue') 从前端调用它,它会正确记录用户 ID。
我什至试过console.log(Meteor.userId)和console.log(Meteor.userId()),都是null。
会发生什么?
【问题讨论】:
标签: javascript meteor