Javascript 如何将JointJS与Meteor一起使用?
我正在试着运行jointjs教程中的示例应用程序,这是我到目前为止得到的 1 sampleApp.htmlJavascript 如何将JointJS与Meteor一起使用?,javascript,backbone.js,meteor,lodash,jointjs,Javascript,Backbone.js,Meteor,Lodash,Jointjs,我正在试着运行jointjs教程中的示例应用程序,这是我到目前为止得到的 1 sampleApp.html <head> <title>sampleApp</title> </head> <body> <h1>Welcome to Meteor!</h1> {{> hello}} </body> <template name="hello"> <d
<head>
<title>sampleApp</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> hello}}
</body>
<template name="hello">
<div></div>
</template>
当我运行此命令时,会出现以下错误:
未捕获的TypeError:u.merge不是functionjoint.dia.Cell.Backbone.Model.extend.constructor@joint.js:3831child@Backbone.js:1408匿名函数@joint.js:7436math@joint.js:39匿名函数@joint.js:44匿名函数@joint.js?518ac863e9f6f1f9a755394c59ad7d562c084829:11194
及
追踪器后冲洗功能异常:
ReferenceError:未定义关节
在[对象]处:3000/app/client/meteor://原来这是一个依赖性问题,我在安装jointjs all时通过命令行降级了主干和Lodash,从而解决了这个问题 meteor添加MX:jointjs all-允许不兼容的更新
从错误消息中可以看出,页面上没有加载下划线。jointjs似乎在使用下划线表示“u.merge…”,但找不到它。这会导致未定义“关节”,因为初始化失败。就这么简单吗?合并的代码。。。是Backbone.js的一部分,我没有接触过,我不确定它引用的是什么。对于未来的搜索者,Backbone.js确实依赖于单独提供的下划线:。从文档中可以看出:主干网唯一的硬依赖项是下划线.js>=1.7.0。
if (Meteor.isClient) {
Template.hello.onRendered(function () {
var graph = new joint.dia.Graph;
var paper = new joint.dia.Paper({
el: this.$('div'),
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]);
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}