Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 嵌套索引路由未在出口中正确呈现_Ember.js - Fatal编程技术网

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(){});
});