Ember.js 嵌套索引路由未在出口中正确呈现
我试图在Ember.js 嵌套索引路由未在出口中正确呈现,ember.js,Ember.js,我试图在取现金/index内部取现金的{{outlet}: router.js: this.route('retirement-options', function () { this.route('taking-cash'); 它不会在插座内部呈现,除非我明确指定/index路径: this.route('retirement-options', function () { this.route('taking-cash', function() { t
取现金/index
内部取现金
的{{outlet}
:
router.js
:
this.route('retirement-options', function () {
this.route('taking-cash');
它不会在插座内部呈现,除非我明确指定/index
路径:
this.route('retirement-options', function () {
this.route('taking-cash', function() {
this.route('index', { path: '' });
});
});
为什么不隐含
/index
,我不能在router.js
中指定它吗?余烬仅为至少有一个子级的路由自动提供索引路由
让我们看一下您的示例:
this.route('retirement-options',函数(){
这条路线(“套现”);
});
这将创建三条路线:
退休选项
退休选项。索引
退休选择。取现金
退休期权。索引
和退休期权。提取现金
两者共享相同的父路径退休期权
退休选项本身不可导航。它将始终解析为退休选项。索引
路线,除非明确的过渡目标提取现金
子路线
一旦您将另一个子路线添加到退休选项。提取现金
将由余烬自动为其创建索引路线
如图所示,您可以通过创建路由来强制执行显式索引路由。但将索引路由作为唯一的叶节点并没有多大价值
请在指南中找到有关索引路由的更多信息:Ember将仅为路由自动提供索引路由,但它不需要专门的子路由。实际上,回调函数必须存在
那么看看这个例子,
this.route('retirement-options',function(){
this.route('taking-cash',function(){
this.route('index',{path:'});
});
});
索引部分不是强制性的。一旦声明了回调函数,索引就会出现
这将与上面的示例完全相同
this.route('retirement-options',function(){
this.route('taking-cash',function(){});
});