node.js - Marionette.js 无法在 'appendChild' : parameter 1 is not of type 'Node' 上执行 'Node'

标签 node.js backbone.js marionette

这是我的布局 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/

相关文章:

node.js - 用于获取给定一个点的边界框的 API 或框架

backbone.js - 使用 typescript 的 Marionette 模块

javascript - 当屏幕尺寸改变时重新执行 api 调用

Backbone.js 在模型中设置 URL 参数并将其与 fetch 一起使用

javascript - 将参数传递给 Marionette 组件?

javascript - 应如何存储多行文本文件?作为文本文件还是js文件?

node.js - 记录 axios 请求和响应 header

javascript - 如何避免事件和悬停背景

node.js - 主干 Node 不工作( headless TDD/开发)

backbone.js - 如何将集合绑定(bind)选择框添加到 Backbone.Marionette 中的表单?