如何在 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屋!
查看全文