如何传递两个匿名函数作为CoffeScript中的参数? [英] How to pass two anonymous functions as arguments in CoffeScript?
本文介绍了如何传递两个匿名函数作为CoffeScript中的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想传递两个匿名函数作为jQuery悬停的参数,例如:
I want to pass two anonymous functions as arguments for jQuery's hover, like so:
$('element').hover(
function() {
// do stuff on mouseover
},
function() {
// do stuff on mouseout
}
);
只需一个 - hover - >
- 但是CoffeeScript中的正确语法是什么?我尝试了 ... hover - >
, ... hover( - > ...
等
It's easy with just one – hover ->
– but what is the proper syntax in CoffeeScript for two? I tried ...hover ->
, ...hover( ->...
, etc. but nothing gets me the above structure.
推荐答案
将括号放在匿名函数的周围。
Put parentheses around the anonymous functions.
这篇关于如何传递两个匿名函数作为CoffeScript中的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文