在Backbone.Marionette文档中,一些声明使我困惑:
您还可以使用路由器上的方法将标准路由添加到AppRouter。
(https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.approuter.md)
现实中看起来如何?
答案 0 :(得分:0)
您可以在AppRouter上添加路由,并定义在路由器或控制器中处理它的方法。
MyRouter = Backbone.Marionette.AppRouter.extend({
// "someMethod" must exist at controller.someMethod
appRoutes: {
"some/route": "someMethod"
"yet/anotherRoute": "routerMethod" // app router route
},
/* standard routes can be mixed with appRoutes/Controllers above */
routes : {
"some/otherRoute" : "someOtherMethod"
},
// method on the router
routerMethod: function() {
// ...
},
someOtherMethod : function(){
// do something here.
}
});