hello世界不能在与jointjs的html中正常工作? [英] hello world does not work properly in html with jointjs?

查看:127
本文介绍了hello世界不能在与jointjs的html中正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是html和joint.js库中的初学者。我有这个代码,一旦我将它保存为html在我的笔记本电脑,它是假设绘制2个连接的矩形,但没有任何显示在浏览器中。
我下载了许多库,并将它们放在具有html页面的相同文件夹中,但没有出现。

I am a beginner in html and the joint.js library. I have this code and once I saved it as html on my laptop, it is suppose to draw 2 connected rectangles but nothing appears in the browser. I downloaded many libraries and put them in the same folder that has the html page but nothing appear too.

我想要做什么?
我在哪里可以放置我想在html代码中使用的库?

What am I suppose to do? Where can I put the libraries that I want to use in html code?

我下载的库是:


  • backbone.js

  • core.js

  • geometry.js

  • joint.all.css

  • joint.all.js

  • joint.all.min.css

  • joint.all.min.js

  • joint.css

  • joint.dia.cell.js

  • joint.dia.element.js

  • joint.dia.graph.js

  • li>
  • joint.dia.paper.js

  • joint.js

  • joint.min.css

  • joint.min.js

  • joint.shapes.devs.js

  • joint.shapes.devs.min.js

  • joint.shapes.erd.js

  • joint.shapes.erd.min.js

  • .shapes.fsa.js

  • joint.shapes.fsa.min.js

  • joint.shapes.org.js

  • joint.shapes.org.min.js

  • jquery.js

  • jquery.sortElements.js

  • lodash.js

  • raphael-min.js

  • raphael.js

  • p> vectorizer.js
  • backbone.js
  • core.js
  • geometry.js
  • joint.all.css
  • joint.all.js
  • joint.all.min.css
  • joint.all.min.js
  • joint.css
  • joint.dia.cell.js
  • joint.dia.element.js
  • joint.dia.graph.js
  • joint.dia.link.js
  • joint.dia.paper.js
  • joint.js
  • joint.min.css
  • joint.min.js
  • joint.shapes.devs.js
  • joint.shapes.devs.min.js
  • joint.shapes.erd.js
  • joint.shapes.erd.min.js
  • joint.shapes.fsa.js
  • joint.shapes.fsa.min.js
  • joint.shapes.org.js
  • joint.shapes.org.min.js
  • jquery.js
  • jquery.sortElements.js
  • lodash.js
  • raphael-min.js
  • raphael.js
  • vectorizer.js

<link rel="stylesheet" type="text/css" href="joint.css" />
<script type="text/javascript" src="joint.js" ></script>    
<script type="text/javascript">

$(function() {    
    var graph = new joint.dia.Graph;

    var paper = new joint.dia.Paper({
         el: $('#myholder'),
         width: 600,
         height: 200,
         model: graph
    });

    var rect = new joint.shapes.basic.Rect({
         position: { x: 100, y: 30 },
         size: { width: 100, height: 30 },
         attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }
    });

    var rect2 = rect.clone();
    rect2.translate(300);

    var link = new joint.dia.Link({
         source: { id: rect.id },
         target: { id: rect2.id }
    });
       graph.addCells([rect, rect2, link]);
})           
</script>


<div id="myholder" >
</div>


感谢大家..
该程序现在工作,我把库的源代码改为网站的URL。如果我使用我在计算机上下载的一次,它不会再工作:

<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src= "http://denknix.com/astro/lib/joint/www/build/joint.all.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://www.jointjs.com/downloads/joint.css" />
<script type="text/javascript" src="http://www.jointjs.com/downloads/joint.js" ></script>   
<script type="text/javascript">
    $(function() {

        var graph = new joint.dia.Graph;

        var paper = new joint.dia.Paper({
             el: $('#myholder'),
             width: 600,
             height: 200,
             model: graph
        });

        var rect = new joint.shapes.basic.Rect({
             position: { x: 100, y: 30 },
             size: { width: 100, height: 30 },
             attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }
        });

        var rect2 = rect.clone();
        rect2.translate(300);

        var link = new joint.dia.Link({
             source: { id: rect.id },
             target: { id: rect2.id }
        });
graph.addCells([rect, rect2, link]);
    })     
    </script>

    <title>Test</title>

</head>
<body>

    <div id="myholder" >
    </div>

</body></html>


推荐答案

注意,您不需要以下两个文件在您的示例中:

Note that you don't need the following two files in your example:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
<script src= "http://denknix.com/astro/lib/joint/www/build/joint.all.min.js"></script>

这是因为jQuery已经包含在 joint.js ,另一个 joint.all.min.js 是JointJS(0.4)的非常旧版本。

This is because jQuery is already included in joint.js and the other joint.all.min.js is a very old version of JointJS (0.4).

您只需要正确包含的其他两个文件:

You only need the other two files that you have correctly included:

<link rel="stylesheet" type="text/css" href="http://www.jointjs.com/downloads/joint.css" />
<script type="text/javascript" src="http://www.jointjs.com/downloads/joint.js" ></script>

问题必须在于将这些文件下载到计算机后如何引用。

The problem must lie in how you reference those files once download them to your computer.

这篇关于hello世界不能在与jointjs的html中正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆