繁体   English   中英

hello world在带有jointjs的html中无法正常工作?

[英]hello world does not work properly in html with jointjs?

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

我该怎么办? 我在哪里可以放置我想在html代码中使用的库?

我下载的库是:

  • 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
  • 拉斐尔-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>

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

<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)的一个非常旧的版本。

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

<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>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM