1
在explaining how to make plugins jQuery的頁面,有這段代碼:jQuery立即在CoffeeScript中調用函數?
(function ($) {
var shade = "#556b2f";
$.fn.greenify = function() {
this.css("color", shade);
return this;
};
}(jQuery));
如何在CoffeeScript的代表呢?如果我試試這個:
do ($) ->
x = 'do nothing'
它作爲編譯:
(function($) {
var x;
return x = 'do nothing';
})($);
我無法弄清楚如何將jQuery
對象傳遞給函數。
這有幫助嗎? - http://coffeescriptcookbook.com/chapters/jquery/plugin – Sgnl 2014-11-09 04:56:43
老實說,我不確定。它保護$別名嗎? – CaptSaltyJack 2014-11-09 04:58:37
就像旁邊,你可以簡單地做'do(jQuery) - > $ = jQuery; ...' – meagar 2014-11-09 20:19:15