你好我试图使用JointJS库执行Hello world应用程序,如下所示: http://www.jointjs.com/tutorial#hello-world 我已经下载了joint.js和joint.css文件 我已经在html文件中复制了HelloWorld教程中给出的代码,并从firefox浏览器中访问了它(26.0) 但它没有按预期工作并在教程中显示。 预计:应该有两个带链接的盒子。 实际:浏览器上没有任何内容。 Ater调试错误是: 在联合.js中的“NS_ERROR_FAILURE:”:
var bbox = this.el.getBBox();
代码是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="joint.css" />
<script src="joint.js"></script>
</head>
<body>
<script type="text/javascript">
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>
</body>
</html>
此致 兰甘特
答案 0 :(得分:6)
你错过了纸质对象的持有人。在打开<body>
标记后立即添加以下内容:
<div id="myholder"></div>
答案 1 :(得分:0)
您可以尝试使用此代码。请添加jquery.min.js lodash.min.js backbone-min.js
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="joint.css" />
<script src="joint.js"></script>
<script src="jquery.min.js"></script>
<script src="lodash.min.js"></script>
<script src="backbone-min.js"></script>
</head>
<body>
<div id="myholder"></div>
<script type="text/javascript">
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>
</body>