2

您好,我正在尝试使用 JointJS 库执行 Hello world 应用程序,如下所示: http ://www.jointjs.com/tutorial#hello-world 我已经下载了joint.js 和joint.css 文件我已经复制了HelloWorld 教程中给出的代码在 html 文件中并从 firefox 浏览器 (26.0) 访问它但它没有按预期工作并在教程中显示。预期:应该有两个带有链接的框。实际:浏览器上没有任何内容。Ater 调试错误为:joint.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>

问候兰加纳特

4

2 回答 2

6

您缺少纸质物品的支架。<body>在开始标记之后添加以下内容:

<div id="myholder"></div>
于 2014-01-21T08:25:40.467 回答
0

你可以试试这段代码。请添加 jquery.min.js lodash.min.js 骨干-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>
于 2016-07-25T03:28:01.700 回答