【问题标题】:newbie: hello world using jointjs新手:使用jointjs的hello world
【发布时间】:2014-01-20 11:56:38
【问题描述】:

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

    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>

问候 兰加纳特

【问题讨论】:

  • 你能展示你的代码吗?
  • @Roy 代码现已添加

标签: jointjs


【解决方案1】:

您缺少纸质物品的支架。在开头的&lt;body&gt; 标签之后添加以下内容:

<div id="myholder"></div>

【讨论】:

    【解决方案2】:

    你可以试试这个代码。请添加 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>
    

    【讨论】:

    • 添加一些描述,只是粘贴代码不行。
    猜你喜欢
    • 2011-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多