2012-01-20 56 views
0
var MyClass = new Class({ 
    foo:function(){ 
     var = new Fung({ 
      go:function(this){ 
       this.bar(); 
      } 
     }); 
    }, 

    bar:function(){ 
     alert('hello world'); 
    } 
}); 

我试图从嵌套类内部访问方法。这可能吗?如何访问JavaScript类中的方法?

+1

您需要显示'Class'构造函数的定义。 – JAAulde

回答

3
var MyClass = new Class({ 
    foo:function(){ 
     var that = this; 
     var = new Fung({ 
      go:function(){ 
       that.bar(); 
      } 
     }); 
    }, 

    bar:function(){ 
     alert('hello world'); 
    } 
});