0

我有这个 Ember 路由器:

App.Router = Em.Router.extend({
    enableLogging: true,
    location: 'hash',    
    root: Em.Route.extend({
        // EVENTS
        gotoList: Ember.Route.transitionTo('list'),

        // STATES
        list: Em.Route.extend({
            route: '/list',
            connectOutlets: function(router, context) {
                router.get('applicationController').connectOutlet('list');
            }
        })
    })
});

我希望该路线'/'将显示列表出口(与 相同'/list'),但我不想复制与列表相同的状态。我可以以某种方式告诉根默认状态是列表吗?

4

1 回答 1

2

也许你在寻找redirectsTo('list')

App.Router = Em.Router.extend({
  enableLogging: true,
  location: 'hash',    
  root: Em.Route.extend({
    // EVENTS

    gotoList: Ember.Route.transitionTo('list'),

    // STATES
    index: Em.Route.extend({
      route: '/',
      redirectsTo: 'list'
    }),

    list: Em.Route.extend({
        route: '/list',
        connectOutlets: function(router, context) {
            router.get('applicationController').connectOutlet('list');
        }
    })
  })
});
于 2012-08-01T22:03:52.317 回答