0

我想在 CoffeeScript 中做类似的事情:

word_list =  [{ text: "cat", weight: 23 }, { text: "mouse", weight: 10 }, { text: "fox", weight: 5}, { text: "lion", weight: 4}, {  text: "giraffe",weight: 3}, {text: "zebra", weight: 2},{ text: "bat", weight: 20 }, { text: "rat", weight: 11 }, { text: "duck", weight: 4}, { text: "dinosaur", weight: 100}, {  text: "flamingo",weight: 50}, {text: "kangaroo", weight: 8},]

$(function() {
    $("#chart").jQCloud(word_list);
});

我会这样打电话吗?

jQuery ->
    $("#chart").jQCloud(word_list);

还是我需要做类似的事情

$ ->
    $chart.jQcloud(word_list);
4

1 回答 1

2

你可以用第一个。或者让它和原来的完全一样:

$ ->
    $('#chart').jQCloud word_list

但是$和 jQuery 是一样的。假设您已经创建$chart,第二个也是有效的。

于 2013-06-25T21:34:58.700 回答