就像我的标题所说的那样,我确实看到Marionette Module现在已被弃用,我们应该使用requirejs来代替AMD模块.这很好,除了模块之外的所有内容都有很好的处理初始化程序和之前:启动和启动事件的目的.它允许我轻松地设置我的区域,视图和集合.现在处理这个的替代方法是什么?
下面是我将使用的代码示例:
define(['core', './views/mainView'], function(core, mainView) {
var app = core.app;
app.start();
return core.app.module('Home Page Module', function(Module) {
Module.addInitializer(function() {
this.region = new core.Marionette.Region({
el: '#page-container'
});
this.collection = [];
});
Module.on('start', function() {
this.view = new mainView({
collection: this.collection
});
this.region.show(this.view);
});
});
});
Run Code Online (Sandbox Code Playgroud)