与方法路由器
问题描述:
在Backbone.Marionette文档添加标准途径一些声明我迷惑不解:与方法路由器
您还可以添加标准路线的AppRouter与路由器上的方法。
(https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.approuter.md)
它怎么可能看起来像在现实中?
答
您可以在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.
}
});