[英]hello world does not work properly in html with jointjs?
我是html和joint.js庫的初學者。 我有這個代碼,一旦我將它保存為我的筆記本電腦上的html,它假設繪制2個連接的矩形,但瀏覽器中沒有任何內容。 我下載了很多庫,並將它們放在具有html頁面的同一個文件夾中,但沒有任何內容。
我該怎么辦? 我在哪里可以放置我想在html代碼中使用的庫?
我下載的庫是:
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.