Jointjs Hello World 空白,控制台中没有错误

Jointjs Hello World blank with no error in console

本文关键字:有错误 控制台 Hello World 空白 Jointjs      更新时间:2023-09-26

我根据他们的 tut 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>

但是我什么也看不到,也没有错误控制台。如果我在最后移动包含,我会得到错误关节未知。

为什么?

您忘记添加创建的矩形和指向图形的链接。

脚本末尾添加此行。

graph.addCells([rect, rect2, link]);

希望这有帮助。