我在javascript中有这个类
var MyGird = Class.extend({
classMemeber1 : "Some Value"
,clickEvent : function(){
this.editor.on({
afteredit: function() {
//
// HOW TO I ACCESS classMemeber1 from here? ?
//
//
}
})
})
我如何从 afteredit 内部访问 classMemeber1 …
谢谢
原文由 fatnjazzy 发布,翻译遵循 CC BY-SA 4.0 许可协议
您需要通过在变量中存储
this
[1]来保存对对象调用clickEvent
函数的引用。由于 _关闭_,它将在afteredit
方法中可用。[1] javascript 中的 this 运算符(注意: ‘this’ 不是运算符)