【发布时间】:2018-11-21 07:40:09
【问题描述】:
我正在从 module.exports 函数中调用本地函数。如何访问exports this 对象?
exports.myVar = 'foo'
exports.myFunc = function() {
localFunc()
}
function localFunc() {
console.log(this.myVar) //Undefined
}
我尝试过使用localFunc().bind(this),但这也不起作用。任何帮助表示赞赏!
【问题讨论】:
-
你想让
this成为什么? -
我希望
this成为foo -
foo在哪里? -
你的意思是你想让
this成为exports?
标签: javascript node.js scope this