Joint.js的帮助和建议

时间:2016-06-24 18:30:52

标签: javascript html jointjs

如何执行joint.js程序?我已经下载了所需的js文件,并将以下代码保存在HTML文件中。我尝试在IE和Chrome中打开,但它导致了一个空白页面:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="joint.css" />
    <script src="jquery.js"></script>
    <script src="lodash.js"></script>
    <script src="backbone.js"></script>
    <script src="joint.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,
        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 }
    });

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

  </script>
</body>
</html>

3 个答案:

答案 0 :(得分:0)

https://github.com/clientIO/joint.git克隆jointjs项目。并转到demo文件夹,在浏览器中打开任何html文件。

我认为这将有助于您开始使用jointjs。

依赖是

 jquery.js
 backbone.js
 joint.js

答案 1 :(得分:0)

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8"/> 
    <link rel="stylesheet" type="text/css" href="css/joint.min.css" /> 
    <link rel="stylesheet" type="text/css" href="css/paper.css" /> 
    <script src="lib/jquery.min.js"></script> 
    <script src="lib/lodash.min.js"></script> 
    <script src="lib/backbone-min.js"></script> 
    <script src="lib/joint.min.js"></script> 
    <script type="text/javascript" src="app.js"></script>
</head>
<body>

答案 2 :(得分:0)

您必须处理下列版本的版本,检查下图中的版本,否则请使用以下CDN。

 <link rel="stylesheet" href="joint.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone.js"></script>

enter image description here