【发布时间】:2015-05-21 16:02:16
【问题描述】:
在使用 node-webkit 时遇到这个奇怪的错误,这是一个可以重新创建它的完整示例:
index.js:
var jQuery = require('jquery');
var Backbone = require('backbone');
(function($){
var ListView = Backbone.View.extend({
el: $('body'),
initialize: function(){
_.bindAll(this, 'render');
this.render();
},
render: function(){
$(this.el).append("<ul> <li>hello world</li> </ul>");
}
});
var listView = new ListView();
})(jQuery);
index.html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./css/main.css" />
</head>
<body>
</body>
<script src="./js/index.js"></script>
</html>
堆栈跟踪:
TypeError: Expecting a function in instanceof check, but got undefined
at _.extend.setElement (C:\SVN\mapthing\branches\mapthing_js\node_modules\backbone\backbone.js:1046:45)
at _.extend._ensureElement (C:\SVN\mapthing\branches\mapthing_js\node_modules\backbone\backbone.js:1108:14)
at Backbone.View (C:\SVN\mapthing\branches\mapthing_js\node_modules\backbone\backbone.js:1000:10)
at new child (C:\SVN\mapthing\branches\mapthing_js\node_modules\backbone\backbone.js:1566:41)
at file:///C:/SVN/mapthing/branches/mapthing_js/js/index.js:18:18
at file:///C:/SVN/mapthing/branches/mapthing_js/js/index.js:19:3
看不出我的问题出在哪里?
大多数解决方案似乎都指向必须首先要求jquery,但我已经这样做了......
我是一个相对的 n00b,所以我期待我做了一些非常愚蠢的事情......
【问题讨论】:
-
我认为你没有打电话给
instanceof?查看导致问题的代码会很有帮助。如果它发生在后台,您可以发布您的堆栈跟踪吗? -
@RobM。我已经编辑以提供一个完整的、最小的示例,它给出了相同的行为,以及堆栈跟踪
标签: javascript node.js node-webkit