为什么jvectormap示例显示空白页?

时间:2013-09-07 03:33:55

标签: jquery jvectormap

http://jvectormap.com/tutorials/getting-started/

以下代码是从上述网页获取的示例中复制的,但我必须更改jquery-jvectormap.css和jquery-jvectormap.js,因为下载的文件名与示例代码不匹配。地图的下载按钮没有下载文件,而是显示我复制并粘贴到名为jquery-jvectormap-world-mill-en.js的文件中的数据。所有文件都与演示文件位于同一目录中。

<!DOCTYPE html>
<html>
<head>
    <title>jVectorMap demo</title>
    <link rel="stylesheet" href="jquery-jvectormap.css" type="text/css" media="screen"/>
    <script src="jquery.js"></script>
    <script src="jquery-jvectormap.js"></script>
    <script src="jquery-jvectormap-world-mill-en.js"></script>
</head>
<body>
    <div id="world-map" style="width: 600px; height: 400px"></div>
    <script>
        $(function(){
            $('#world-map').vectorMap();
        });
    </script>
</body>
</html>

在浏览器中显示的结果是全白网页。我是网络编程的新手,但在我看来,$('#world-map')。vectorMap();应该提供一些信息来说明要使用哪个地图。请帮忙。

一些例子很精彩,它们解释了代码的作用以及资源需要驻留的位置。其他人希望你直观地知道这一切是如何运作的,但是当你在学习时你却不知道。 “免费”软件并不总是免费的,有时它会带来成本,时间和压力,我会尽快付钱。

3 个答案:

答案 0 :(得分:1)

很抱歉要迟到,但问题很可能是该行

<script src="jquery.js"></script>

失败(如果您在Web浏览器中查看调试消息,您会发现行 ReferenceError jquery未定义 - 例如在Firefox中右键菜单:Inspect Element - &gt; Console然后重新加载页面。)

我不确定你在运行什么系统,但在Linux中,jquery.js通常是在      /usr/share/javascript/jquery/jquery.js

所以,替换

<script src="jquery.js"></script>

<script src="/usr/share/javascript/jquery/jquery.js"></script>

或者,如果您有网络服务器,请确保它知道jquery.js的位置。

答案 1 :(得分:0)

有效,here's the proof

您可能没有正确指向html中的文件。

您无需指向地图,“地图”的默认值为“world_mill_en”:

jvm.WorldMap.defaultParams = {
    map: "world_mill_en",

这是jquery-jvectormap-1.2.2.min.js的摘录,它使$('#world-map').vectorMap()完全正常。

答案 2 :(得分:0)

我遇到了与你完全相同的问题,我发现保罗提到我需要使路径相对,但除了该解决方案之外,我还必须修改我正在使用的地图jquery文件,从而替换&# 34; jquery的&#34; $只是如下:

&LT; ----! 原始档案: - &GT;

jquery.fn.vectorMap(&#39; addMap&#39; ..)

&LT; ----! 修改文件: - &GT;

$ fn.vectorMap(&#39; addMap&#39; ...)。

随意参考以下论坛帖子: https://forum.jquery.com/topic/trying-to-get-jvectormap-working