简体   繁体   English

JointJS:Hello World示例不起作用

[英]JointJS:Hello World example doesn't work

Hello I'm trying to execute Hello world application using JointJS library as given in: http://www.jointjs.com/tutorial#hello-world 您好,我正在尝试使用JointJS库执行Hello world应用程序,具体方法JointJShttp : //www.jointjs.com/tutorial#hello-world

I have downloaded joint.js(1.0.2) and joint.css files, copied the code given in HelloWorld tutorial in html file, and accessed it from the Chrome browser but it's not working as shown in the tutorial. 我已经下载了joint.js(1.0.2)joint.css文件,将HelloWorld教程中给出的代码复制为html文件,并通过Chrome浏览器访问了它,但无法按教程中所示进行操作。

Console.error: Uncaught TypeError: this.addCell is not a function Console.error:未捕获的TypeError:this.addCell不是函数

html is: HTML是:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content=""/>
<meta name="author" content=""/>
<title>diagram</title>
<link rel="stylesheet" href="node_modules/joint/joint.min.css">

<body>
   <div id="diaHolder">

   </div>

  <script src="node_modules/jquery/dist/jquery.min.js"></script>
  <script src="node_modules/lodash/lodash.min.js"></script>
  <script src="node_modules/backbone/backbone-min.js"></script>
  <script src="node_modules/joint/joint.min.js"></script>
  <script>
   var graph = new joint.dia.Graph;
   var paper = new joint.dia.Paper({
       el: $('#diaHolder'),
       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>

check versions of dependencies, especial Lodash. 检查依赖版本,特别是Lodash。 JointJS it's not compatible with version 4.x JointJS它与4.x版本不兼容

jQuery: 2.2.4 的jQuery:2.2.4
Lodash: 3.10.1 Lodash:3.10.1
Backbone: 1.3.3 骨干:1.3.3

只是把它扔在那里,但是您有一个起始html标记吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM