backbone.js调用视图时this._configure未定义
类型错误:表达式“this._configure”[未定义]的结果不是函数。
时,我都会遇到此错误
每当我扩展 Backbone.View我的应用程序结构如下所示
: //index.js
$(function(){
window.Project = Backbone.Model.extend({});
window.ProjectCollection = Backbone.Collection.extend({});
window.projects = new ProjectCollection;
window.ProjectView = Backbone.View.extend({});
window.view = ProjectView({});
window.view.render();
});
即使使用此空白结构,我仍然会收到错误,当我填写所有代码时,我会收到完全相同的错误
我缺少依赖吗?在我的 index.html 中,我按顺序加载以下内容:
jquery.js
underscore.js
backbone.js
(and at the bottom of my body) index.js
如果我从变量中取出“窗口”,我会得到相同的错误。
无论我如何处理backbone.js,我都会遇到同样的错误...我该如何解决这个问题?
TypeError: Result of expression 'this._configure' [undefined] is not a function.
I keep running into this error any time I extend Backbone.View
my app structure looks like :
//index.js
$(function(){
window.Project = Backbone.Model.extend({});
window.ProjectCollection = Backbone.Collection.extend({});
window.projects = new ProjectCollection;
window.ProjectView = Backbone.View.extend({});
window.view = ProjectView({});
window.view.render();
});
Even with this blank structure I still get the error, and when I have all my code filled in I get the exact same error
Am I missing a dependancy? in my index.html I load the following in order:
jquery.js
underscore.js
backbone.js
(and at the bottom of my body) index.js
And if I take the 'window' off of my variables i get the same error.
No matter how I approach backbone.js I keep getting this same error... how do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试
代替
Try
instead of
我最近也看到了这个错误
TypeError: this._configure is not a function
这是因为我有:var myView = someView();
而不是:
var myView = new someView();
I was recently seeing this error too
TypeError: this._configure is not a function
and it was because I had:var myView = someView();
instead of:
var myView = new someView();
我需要将论据传递给我的观点,所以这里的选项都不适合我。
我有这个代码:
将其更改为有效:
I needed to pass arguments to my view, so none of the options here worked for me.
I had this code:
Changing it to this worked: