1
當用戶登錄到我的/settings
頁面時,我想將其重定向到/settings/overview
。我怎樣才能完成這個只有當他們登陸在/settings
,但他們着陸時不火,例如,/settings/account
?只有在路由視圖上着陸時,Ember路由方法
當用戶登錄到我的/settings
頁面時,我想將其重定向到/settings/overview
。我怎樣才能完成這個只有當他們登陸在/settings
,但他們着陸時不火,例如,/settings/account
?只有在路由視圖上着陸時,Ember路由方法
創建一個SettingsIndexRoute
並在它們到達該路線時重定向。只有當你點擊資源的根目錄時,索引路線纔會被擊中。
App.SettingsIndexRoute = Em.Route.extend({
redirect: function(){
// I'm assuming overview is a route under settings
// and not a resource under it
this.transitionTo('settings.overview');
}
});
謝謝 - 我使用的是ember-cli,所以創建了一個/routes/settings/index.js文件並添加了這個功能 - 效果很好。 – Sam