backbone.js调用视图时this._configure未定义

发布于 2024-10-20 11:23:14 字数 706 浏览 3 评论 0原文

类型错误:表达式“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

和影子一齐双人舞 2024-10-27 11:23:14

尝试

window.view = new ProjectView;

代替

window.view = ProjectView({});

Try

window.view = new ProjectView;

instead of

window.view = ProjectView({});
任性一次 2024-10-27 11:23:14

我最近也看到了这个错误 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();

若沐 2024-10-27 11:23:14

我需要将论据传递给我的观点,所以这里的选项都不适合我。

我有这个代码:

return new app.module('foo').View({id: 1});

将其更改为有效:

var view = app.module('foo').View;
return new view({id: 1});

I needed to pass arguments to my view, so none of the options here worked for me.

I had this code:

return new app.module('foo').View({id: 1});

Changing it to this worked:

var view = app.module('foo').View;
return new view({id: 1});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文