內部調用一個方法我有一個節點類是這樣的:從另一個類
var Classes = function() {
};
Classes.prototype.methodOne = function() {
//do something
};
時,我想打電話給
methodOne
,我用這個:
this. methodOne();
和它的作品。但是現在我必須從另一個課程的另一種方法中調用它。這一次,它不是作品和無法訪問methodOne
:
var mongoose = new Mongoose();
mongoose.save(function (err, coll) {
//save to database
this. methodOne(); //this does not work
}
我怎麼可以叫methodOne?我使用Classes.methodOne()
但它不能正常工作
這是指貓鼬類 –
@wZVanG:是的,但我想訪問主類 – Fcoder