coffeescript传递require()参数错误
代码require ('./routes') app
编译require('./routes'(app));
但我需要它来编译require('./routes)(app)
。 我怎么能这样做?
括号在CoffeeScript中有两个用途:
- 他们组expression式:
(a + b) * c
- 他们习惯于调用函数:
f(x)
。
当你这样说的时候:
f (x)
关于x
的括号有什么含糊不清的地方; 他们分组括号或函数调用括号? CoffeeScriptselect前者。
如果你想(或需要)使用圆括号来调用一个函数,你不需要在左括号之前的空格,你想要:
f(x)
在你的情况下,你会想要:
require('./routes') app
甚至:
require('./routes')(app) (require './routes') app