当我尝试来自 JointJS 站点的 Hello World 示例时,我总是看到此异常:
Uncaught TypeError: Cannot call method 'getStrokeBBox' of undefined
这是代码:
<!DOCTYPE html>
<html>
<head>
<!--
<link rel="stylesheet" href="css/joint.css" />
<script src="js/joint.js"></script>
-->
<link rel="stylesheet" type="text/css" href="http://www.jointjs.com/downloads/joint.css"></link>
<script type="text/javascript" src="http://www.jointjs.com/downloads/joint.js" ></script>
<script>
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>
</head>
<title>Test</title>
<body>
<div id="myholder"> </div>
</body>
</html>
我看到这里已经针对同一个问题提出了另一个问题,但是那里给出的解决方案不相关,因为我已经有一个用于纸质对象的 div 元素。