在emberjs路线中,我有
App.Router.map(function() {
this.resource('about');
this.resource('projects');
});
当我点击/about
时会显示 关于页面,而当我点击/projects
时会显示项目页面。
即使在/
以及/about
中,如何让关于页面显示?
Rails相当于
root to: "pages#about"
get 'about', to: 'pages#about'
get 'projects', to: 'pages#projects'
答案 0 :(得分:0)
默认情况下,ember会生成一个IndexRoute映射到'/'
App.Router.map(function() {
// By default ember generates a IndexRoute mapping to '/'
// this.route('index', { path: '/' });
this.resource('about');
this.resource('projects');
});
App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
this.transitionTo('about');
}
});
因此,您可以覆盖beforeModel
从IndexRoute
转换为about
路线。