【问题标题】:EmberJS: splitting the router into multiple filesEmberJS:将路由器拆分为多个文件
【发布时间】:2012-09-07 00:45:36
【问题描述】:

谁能举个很好的例子来说明如何将路由器分成多个文件,是否有这样做的最佳实践?

【问题讨论】:

    标签: javascript ember.js ember-old-router


    【解决方案1】:

    这是我正在做的一个非常简化的版本。只需确保您需要的文件顺序正确。

    //router.js
    App.Router = Ember.Router.extend({
      accounts: App.AccountsRoutes.extend({
        route: "/account"
      })
      // more routes here
    })
    
    //account_routes.js
    App.AccountRoutes = Ember.Route.extend({
      index: Ember.Route.extend({
        route: '/',
        connectOutlets: function(router){
           // connect here
        }
      })
      // more routes here
    })
    

    【讨论】:

      猜你喜欢
      • 2018-03-05
      • 2011-11-10
      • 1970-01-01
      • 2017-08-15
      • 2018-06-24
      • 1970-01-01
      • 2020-11-09
      • 2020-08-04
      • 2013-08-24
      相关资源
      最近更新 更多