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