Javascript-为什么不在Backbone.js中设置集合?
作者:互联网
以下代码有什么问题?
var Item = Backbone.Model.extend({
defaults: {
}
});
var List = Backbone.Collection.extend({
model: Item
});
var collection = new List({'variable':this}); //collection is NOT null!
var result = new Item({'collection':collection}); //result.collection is undefined! why?
解决方法:
将您的商品添加到列表
var collection=new List,
result=new Item({ name: 'my item'});
collection.add( result );
要么
collection.create({ name: 'my item'});
标签:backbone-js,javascript,jquery 来源: https://codeday.me/bug/20191202/2085195.html