EmberJS 嵌套子路由自定义索引路径未按预期工作
EmberJS nested subroute custom index path not working as expected
我正在关注 one of the Ember Guides on routing (v2.14.0),我正在尝试设置一个嵌套子路由,其中索引路由应重定向到不同的子路由。
Router.map(function() {
this.route('about');
this.route('dashboard', function() {
this.route('index', { path: '/dashboard/calendar'});
// ^should direct all dashboard index requests to dashboard/calendar right?
// setting path = '/calendar' also doesn't work
this.route('calendar');
this.route('daily-journal');
});
});
然而,当我加载 http://localhost:3000/dashboard
时,出现此错误:
知道我做错了什么吗?
如果您想重定向到另一条路线/从仪表板-您可以使用路线的重定向:https://guides.emberjs.com/v2.14.0/routing/redirection/
您只需在仪表板索引路由中添加一些内容
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
this.transitionTo('dashboard.calendar');
}
});
我正在关注 one of the Ember Guides on routing (v2.14.0),我正在尝试设置一个嵌套子路由,其中索引路由应重定向到不同的子路由。
Router.map(function() {
this.route('about');
this.route('dashboard', function() {
this.route('index', { path: '/dashboard/calendar'});
// ^should direct all dashboard index requests to dashboard/calendar right?
// setting path = '/calendar' also doesn't work
this.route('calendar');
this.route('daily-journal');
});
});
然而,当我加载 http://localhost:3000/dashboard
时,出现此错误:
知道我做错了什么吗?
如果您想重定向到另一条路线/从仪表板-您可以使用路线的重定向:https://guides.emberjs.com/v2.14.0/routing/redirection/
您只需在仪表板索引路由中添加一些内容
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel() {
this.transitionTo('dashboard.calendar');
}
});