4

使用 Backbone.View 我曾经以这种方式获取外部模板(1)

如果我想使用 Backbone.Marionette.Layout 从外部文件中获取模板怎么办?(2)


(1)

define(['myTemplate.html'], function (myTemplate) {
    var MyView = Backbone.View.extend({
        render: function ()
        {
            this.$el.html(myTemplate, this.getView());
        }
    });

    return MyView;
});

(2)

define(['myTemplate.html'], function (myTemplate) {
    var Layout = Backbone.Marionette.Layout.extend({

        template: "#container",

        regions: {
            top: "#top",
            main: "#main"
        }
    });

    return Layout;
});
4

1 回答 1

2

看看这个:https ://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs

this.$el.html(myTemplate, this.getView()); 
于 2013-06-12T17:46:50.600 回答