1
我的例子:錯誤:需要的CollectionView ItemView控件
var stooges = [{ name: 'moe', age: 44, userid: 1},
{ name: 'larry', age: 44, userid: 2},
{ name: 'curly', age: 44, userid: 3}];
var StoogeModel = Backbone.Model.extend({});
var StoogeCollection = Backbone.Collection.extend({
model: StoogeModel
});
var StoogeItemView = Backbone.Marionette.ItemView.extend({
tagName: "tr",
template: '#stooge-template'
});
var StoogesCollectionView = Backbone.Marionette.CollectionView.extend({
tagName: "table",
childView: StoogeItemView
});
var myStooges = new StoogeCollection(stooges);
var myStoogesView = new StoogesCollectionView({ collection: myStooges });
myStoogesView.render();
document.body.appendChild(myStoogesView.el);
這個例子我在話題backbone.js collection view example using marionette template讀,但我有錯誤:
marionette_backbone.js:1299未捕獲NoItemViewError:一個itemView
必須指定
請幫助我。
您使用哪個版本的木偶? – Cyclone
我不確定,但可能是因爲某些版本不匹配,我複製粘貼你的代碼在[這個小提琴](https://jsfiddle.net/cyclone/f70z64ef/1/),添加庫,它似乎是加工。 – Cyclone