我正在尝试重定向/仪表板/到/仪表板/覆盖/人口统计,如果网址命中/仪表板/.
问题是,如果我点击像**/仪表板/流量这样的子路由,我仍然会被重定向到/ dashboard/reach/demographic /.
Ember的做法是什么?
这是我的代码:
(function() {
App.Router.map(function(match) {
this.resource('dashboard', function() {
this.resource('traffic', function() {
this.route('visits');
this.route('pageviews');
return this.route('duration');
});
return this.resource('reach', function() {
this.route('demographics');
this.route('over_time');
return this.route('devices');
});
});
return this.route('audience');
});
App.DashboardRoute = Ember.Route.extend({
redirect: function() {
return this.transitionTo('reach.demographics');
}
});
if (!App.ie()) {
App.Router.reopen({
location: 'history'
});
}
App.reopen({
rootUrl: '/'
});
}).call(this);
Run Code Online (Sandbox Code Playgroud)
在DashboardIndexRoute而不是DashboardRoute中实现重定向.
App.DashboardIndexRoute = Ember.Route.extend({
redirect: function() {
return this.transitionTo('reach.demographics');
}
});
Run Code Online (Sandbox Code Playgroud)
我为你创建了一个jsbin示例.尝试:
http://jsbin.com/odekus/6#/dashboard/
http://jsbin.com/odekus/6#/dashboard/traffic
我还从代码中删除了不必要的返回.
| 归档时间: |
|
| 查看次数: |
742 次 |
| 最近记录: |