2013-02-13 2 views

답변

4

에서 방법을 참조하려고

생성자 함수 자체이다. 당신이 C.f를 작성해야 f

는 클래스 메소드에 액세스하려면 :

class C 

    @f:() -> 
     alert 'works' 
     null 

    constructor:() -> 
     console.log C.f 
     document.onclick = C.f 
+1

인스턴스 메서드가 아닌 클래스 메소드를 결합하고 싶었다 가정합니다. 클래스 이름을 명시 적으로 드래그하지 않으려면 'f'를 입력하십시오. –

+0

예, @muistooshort에 대한 감사도 작동합니다! :-) – zbynour

3

난 당신이 또한`@constructor를 사용할 수

class C 
    #this defines a class method 
    @f:() -> 
     alert 'works' 
     null 

    #this is an instance method 
    f:() -> 
     alert 'works' 
     null 

    constructor:() -> 
     console.log @f # why is this undefined? 
     document.onclick = @f 

new C() 
관련 문제