【问题标题】:Jointjs error on Nodejs server - Uncaught ReferenceError:Joint is not definedNodejs服务器上的Jointjs错误-未捕获的ReferenceError:未定义关节
【发布时间】:2016-10-02 17:14:43
【问题描述】:

我有以下代码在节点服务器上的文件上制作示例图

<!DOCTYPE html>
<html>
<head>
  <title>newpageshere</title>
<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>

但是当我运行它时,它什么也没显示。在开发人员控制台中,我收到以下错误 var graph = new joint.dia.Graph;

错误: 未捕获的 ReferenceError:未定义关节

当我在 XAMPP localhost 上运行该文件时,它似乎运行良好,但当我在 node.js 服务器上运行它时却不行。我还需要在上面配置服务器吗?或者有人可以在这里看到错误吗?

【问题讨论】:

    标签: javascript node.js jointjs


    【解决方案1】:

    如果未定义joint,则似乎未正确加载joint.js 文件。或者是吗?您可以在浏览器的开发人员工具的网络选项卡中检查这一点。如果确实如此,那么您必须检查在服务器端提供静态文件(脚本/样式表)的根目录是什么。

    【讨论】:

      猜你喜欢
      • 2021-07-12
      • 1970-01-01
      • 1970-01-01
      • 2020-02-02
      • 2014-10-21
      • 2023-03-04
      • 2019-12-28
      • 1970-01-01
      • 2023-01-23
      相关资源
      最近更新 更多