【发布时间】:2012-10-24 20:23:09
【问题描述】:
我有一个不明白的范围问题。
我有这个对象有一些方法:
FileInfo = (file) ->
@name = path.basename(file.path);
FileInfo::uploadImage = (filename, callback) ->
FileInfo::handleImage = (version, callback) ->
# Here I would like to call uploadImage
我从 async.forEach 循环中调用 handleImage 为:
async.forEach options, fileInfo.handleImage, (err) -
我想从 handleImage 中调用 uploadImage,但我得到 TypeError: Object # has no method 'uploadImage'
我在 handleImage 内部尝试了以下内容:
this.uploadImage
还有:
that = this
that.uploadImage
都不行。
如果我在 forEach 循环之外调用 fileInfo.handleImage,它可以很好地处理这个或那个。
【问题讨论】:
标签: javascript node.js asynchronous coffeescript