【问题标题】:jQCloud not workingjQCloud 不工作
【发布时间】:2016-07-27 21:37:51
【问题描述】:

我正在尝试实现 jQCloud 库,但是当我尝试使用它时,我的浏览器显示了我

$(...).jQCloud is not a function

jqcloud的来源是https://github.com/lucaong/jQCloud/blob/master/jqcloud/jqcloud-1.0.4.min.js

页面代码(带有django templatetag):

    {% load static %}
    <!doctype html public "lice">
    <head>
        <meta charset="utf-8">
        <title>jqcloud</title>
        <script type="text/javascript" src="{% static "home/jqcloud.js" %}"></script>
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>

    <script type="text/javascript">
    var word_list = [
       {text: "Lorem", weight: 15},
       {text: "Ipsum", weight: 9, link: "http://jquery.com/"},
       {text: "Dolor", weight: 6},
       {text: "Sit", weight: 7},
       {text: "Amet", weight: 5}
       // ...other words
    ];
    $(document).ready(function() {
       $("#wordcloud").jQCloud(word_list);
    });
    </script>
    </head>
    <body>
    <div id="wordcloud" style="width: 550px; height: 350px; position: relative;"></div>
    </body>
    </html>

【问题讨论】:

  • 只需在浏览器中打开页面,在浏览器中查看页面的源代码并检查jqcloud.js文件是否正确加载...您也可以查看开发人员上的网络选项卡工具(Chrome 上 F12),并检查文件是否被正确调用
  • @Hackerman 我什至将所有内容从 jqcloud.js 移到了 html 页面,仍然是同样的错误。顺便说一句,我忘了提 - js 文件末尾有一个(jQuery),我删除了它,导致浏览器控制台说“未捕获的 ReferenceError:jQuery 未定义”。也许是关键?
  • 我只是意识到你需要颠倒脚本的顺序..first jquery 然后 jqcloud :)

标签: jquery tag-cloud


【解决方案1】:

您在依赖 jQuery 之前调用了 JQCloud 库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    • 2019-01-19
    • 1970-01-01
    相关资源
    最近更新 更多