[英]JointJS:Hello World example doesn't work
您好,我正在嘗試使用JointJS
庫執行Hello world應用程序,具體方法JointJS
: http : //www.jointjs.com/tutorial#hello-world
我已經下載了joint.js(1.0.2)
和joint.css
文件,將HelloWorld教程中給出的代碼復制為html文件,並通過Chrome瀏覽器訪問了它,但無法按教程中所示進行操作。
Console.error:未捕獲的TypeError:this.addCell不是函數
HTML是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content=""/>
<meta name="author" content=""/>
<title>diagram</title>
<link rel="stylesheet" href="node_modules/joint/joint.min.css">
<body>
<div id="diaHolder">
</div>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/lodash/lodash.min.js"></script>
<script src="node_modules/backbone/backbone-min.js"></script>
<script src="node_modules/joint/joint.min.js"></script>
<script>
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#diaHolder'),
width: 600,
height: 200,
model: graph,
gridSize: 1
});
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>
</body>
</html>
檢查依賴版本,特別是Lodash。 JointJS它與4.x版本不兼容
的jQuery:2.2.4
Lodash:3.10.1
骨干:1.3.3
只是把它扔在那里,但是您有一個起始html標記嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.