我在将此特定代码添加到我的路由器文件中时遇到此错误。这是我的路由器文件的代码。
card = new Cards();
我的收藏文件非常简单。
var AppRouter = Backbone.Router.extend({
routes: {
"": "home",
"build/:deck": "deckbuilder",
"decks/:id": "deckviewer",
},
deckbuilder: function(decks){
var cards = new Cards();
this.deckbuild = new Deckbuilder();
$('#content').html(this.deckbuild.el);
}
});
我一直试图找出错误但错误立即出现在我的backbone.js供应商文件中。查看跟踪后,调用此行window.Card = new Backbone.Model.extend({});
window.Cards = new Backbone.Collection.extend({
model: Card,
url: "/cards"
});
后出现错误。但是,我不知道如何解决它。
答案 0 :(得分:7)
从new
和window.Card = new Backbone.Model.extend({});
移除window.Cards = new Backbone.Collection.extend({});
。
你需要使用它:
window.Card = Backbone.Model.extend({});
window.Cards = Backbone.Collection.extend({});