【问题标题】:Add standard routes with methods on the router使用路由器上的方法添加标准路由
【发布时间】:2013-04-12 04:51:20
【问题描述】:

在 Backbone.Marionette 文档中,一些语句让我感到困惑:

您还可以使用路由器上的方法将标准路由添加到 AppRouter。

(https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.approuter.md)

它在现实中会是什么样子?

【问题讨论】:

    标签: backbone.js marionette


    【解决方案1】:

    您可以在 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.
      }
    });
    

    【讨论】:

      猜你喜欢
      • 2022-01-15
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多