2011-08-15 6 views

答えて

9

​​イベントハンドラの内部では、thisの値はオブジェクトを参照しないため、DOM要素を参照します。

class C 
    constructor:() -> 
    @date = new Date() 

    f:() -> 
    $(document).keydown((e) => 
     alert(@date) 
    ) 
:そのために

、あなたは親thisにハンドラのthis値を結合すること、=>fat arrow)を使用することができます