我是根据他们的啧啧http://jointjs.com/tutorial
创建的<html>
<head>
<title></title>
</head>
<body>
<div id="myholder" >
</div>
<link rel="stylesheet" type="text/css" href="joint.css">
<script type="text/javascript" src="joint.js"></script>
<script type="text/javascript">
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: $('#myholder'),
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 }
});
</script>
</body>
</html>
但我看不到任何错误控制台。如果我在最后移动包含,我会得到错误联合未知。
为什么?
答案 0 :(得分:1)
您忘了添加创建的矩形和图表链接。
在脚本末尾添加此行。
graph.addCells([rect, rect2, link]);
希望这有帮助。