我有一个像这样定义的 CoffeeScipt 类
class Foo
a: 1
b: 2
main: ->
if a == 1
log(1)
log: (num) ->
console.log(num)
f = new Foo
f.main()
它不断出错,说未定义日志。我试着让它@log:
也不起作用。我尝试制作->
main a=>
并没有工作。如何从类本身调用实例方法?
我有一个像这样定义的 CoffeeScipt 类
class Foo
a: 1
b: 2
main: ->
if a == 1
log(1)
log: (num) ->
console.log(num)
f = new Foo
f.main()
它不断出错,说未定义日志。我试着让它@log:
也不起作用。我尝试制作->
main a=>
并没有工作。如何从类本身调用实例方法?