这是我的布局 View :
define(["marionette", "lodash", "text!fonts/template.html",
"fonts/controls/view", "fonts/products/view"],
function(Marionette, _, templateHTML, ControlsView, ProductsView) {
'use strict';
var FontsView = Marionette.LayoutView.extend({
regions: {
controls: '#controls',
products: '#products-list'
},
template: _.template(templateHTML),
onRender: function() {
this.getRegion('controls').show(new ControlsView());
this.getRegion('products').show(new ProductsView());
}
});
return FontsView;
});
这是我的产品 View :
define(["marionette", "lodash", "text!fonts/products/template.html",
'fonts/products/item-view', 'fonts/products/collection'],
function(Marionette, _, templateHTML, ProductItemView, ProductsCollection) {
'use strict';
var ProductsView = Marionette.CompositeView.extend({
el: '.items',
template: _.template(templateHTML),
childView: ProductItemView,
initialize: function() {
this.collection = new ProductsCollection();
}
});
return ProductsView;
});
错误(来自控制台)发生在 this.getRegion('products').show(new ProductsView());
最佳答案
从 ProductsView 中删除 el: '.items',
即可正常工作。 Marionette 已经在管理该区域,并且在 subview 上指定 el 时会感到困惑。
关于node.js - Marionette.js 无法在 'appendChild' : parameter 1 is not of type 'Node' 上执行 'Node',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31144881/