[英]Uncaught TypeError: Cannot read property 'push' of undefined - when trying to JointJS Hello World example
I'm trying to get the JointJS 'Hello World' example to work 我正在尝试让JointJS“ Hello World”示例起作用
Reference: https://resources.jointjs.com/tutorial/hello-world 参考: https : //resources.jointjs.com/tutorial/hello-world
The dependencies are all loaded in the correct order but I can't get around the following exception: Uncaught TypeError: Cannot read property 'push' of undefined
when trying to run the example. 所有依赖项都以正确的顺序加载,但是我Uncaught TypeError: Cannot read property 'push' of undefined
以下异常: Uncaught TypeError: Cannot read property 'push' of undefined
尝试运行示例时, Uncaught TypeError: Cannot read property 'push' of undefined
。
I realize that Backbone requires underscore but I read in a different article that Backbone 1.3.3 should be compatible with Lodash. 我意识到Backbone需要下划线,但是我在另一篇文章中读到Backbone 1.3.3应该与Lodash兼容。 When I do include underscore it seems to conflict with lodash (which jointjs requires). 当我添加下划线时,似乎与lodash(jointjs要求)冲突。 eg. 例如。 '_.create is not defined'. “ _.create未定义”。
I've tried a multitude of different versions to no avail. 我尝试了许多不同的版本都没有用。
Here's a jsfiddle where I'm trying to get it to work in. 这是一个jsfiddle,我正在尝试使其运行。
https://jsfiddle.net/0mdg8xja/1/ https://jsfiddle.net/0mdg8xja/1/
What am I doing wrong and how can I get around this exception in this scenario? 我在做什么错?在这种情况下如何解决此异常?
I came to the idea of looking up existing JSFiddles and stumbled upon this one: 我想到了查找现有的JSFiddles的想法,偶然发现了这一点:
https://jsfiddle.net/robertrozas/gfaL9ype/ https://jsfiddle.net/robertrozas/gfaL9ype/
I compared the hello world example to this one and it appears that the only thing I was missing was the fact that I had to wrap the javascript inside: 我将hello world示例与此示例进行了比较,似乎我所缺少的唯一一件事就是必须将javascript包装在其中:
$(function(){ });
This seems to work regardless of what versions I use. 无论我使用什么版本,这似乎都可以工作。 I tested it on JointJS 0.9.7
and 1.1.0
, backbone 1.1
, 1.3.3
and lodash 3.10.1
. 我测试JointJS 0.9.7
和1.1.0
,骨干1.1
, 1.3.3
和lodash 3.10.1
。
Here's the updated JSFiddle for if anyone stumbled upon the same foreheadsmacker as I did. 如果有人像我一样偶然碰到了相同的额头,这就是更新的JSFiddle。
https://jsfiddle.net/gfaL9ype/30/ https://jsfiddle.net/gfaL9ype/30/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.