发布于 2012-04-14 21:18:02
编辑:由于Ember.js路由器的重大变化,此答案在1.0预发行版中已过时。MOdern版本的ember.js应该
我猜这(至少现在)是非常私人的。我喜欢亨普顿的ember routemanager。如果你需要帮助,我可以帮你。再加上他的ember-layout包,它们在一起工作得很好。
http://codebrief.com/2012/02/anatomy-of-a-complex-ember-js-app-part-i-states-and-routes/
发布于 2012-05-22 22:37:01
路由最近在核心Ember.js中可用,请参阅Tom Dale的blog post。
核心开发人员Yehuda Katz写了一篇关于新路由功能用法的gist。这是一个很好的读物,除了路由之外,还说明了它如何与控制器集成。
为了获得基本概念,这里有一个摘自大意的代码示例:
App.Router = Ember.Router.extend({
root: Ember.State.extend({
index: Ember.State.extend({
route: '/',
redirectsTo: 'calendar.index'
}),
calendar: Ember.State.extend({
route: '/calendar',
index: Ember.State.extend({
route: '/'
}),
preferences: Ember.State.extend({
route: '/preferences'
})
}),
mail: Ember.State.extend({
route: '/mail',
index: Ember.State.extend({
route: '/'
}),
preferences: Ember.State.extend({
route: '/preferences'
})
})
})
});
// If the user navigates to the page with the URL
// www.myapp.com/, you will start in the root.calendar.index state.
// The redirection to the calendar.index state will cause the URL
// to be updated to www.myapp.com/calendar
router.transitionTo('preferences');
// URL => www.myapp.com/calendar/preferences
router.transitionTo('mail.preferences');
// URL => www.myapp.com/mail/preferences
router.transitionTo('index');
// URL => www.myapp.com/mail发布于 2012-04-16 21:15:43
我在我的应用程序中使用sproutcore-routing是因为:
有关文档,请查看spoutcore-routing tests
https://stackoverflow.com/questions/10151202
复制相似问题