【发布时间】:2015-06-01 14:27:33
【问题描述】:
我需要为每个登录的用户调用几次函数,但是当该函数放在meteor方法中时,this.userId在函数范围内变为未定义,示例如下:
myMethod: function(){
console.log(this.userId); // this returns proper userId
function innerFunction(){
console.log(this.userId); // this returns undefined
};
innerFunction();
}
如何在函数中传递 this.userId? 函数是否必须与 Meteor.bindEnvironment 绑定?
【问题讨论】:
-
你试过写成
Meteor.userId()吗?
标签: javascript methods meteor