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路由器API中嵌套视图?_Ember.js - Fatal编程技术网

如何在新的Ember.js路由器API中嵌套视图?

如何在新的Ember.js路由器API中嵌套视图?,ember.js,Ember.js,我有一个设置屏幕,它由一个边栏和一个主体组成。正文可以有一个表单来更新用户的配置文件或密码 路由如下所示: App.Router.map(function(match) { (match("/")).to("index"); (match("/user")).to("user", function(match) { (match("/")).to("userIdx"); (match("/settings")).to("userSetup", function(match

我有一个设置屏幕,它由一个边栏和一个主体组成。正文可以有一个表单来更新用户的配置文件或密码

路由如下所示:

App.Router.map(function(match) {
  (match("/")).to("index");
  (match("/user")).to("user", function(match) {
    (match("/")).to("userIdx");
    (match("/settings")).to("userSetup", function(match) {
      (match("/")).to("userSetupIdx");
      (match("/profile")).to("userSetupProfile");
      (match("/password")).to("userSetupPassword");
    });
  });
});
<script type="text/x-handlebars" data-template-name="userSetup">
  <div class='sidebar'>
    Sidebar
  </div>
  <div class='main'>
    Setup <br/>
    {{outlet}}
  </div>
</script>
包装设置模板如下所示:

App.Router.map(function(match) {
  (match("/")).to("index");
  (match("/user")).to("user", function(match) {
    (match("/")).to("userIdx");
    (match("/settings")).to("userSetup", function(match) {
      (match("/")).to("userSetupIdx");
      (match("/profile")).to("userSetupProfile");
      (match("/password")).to("userSetupPassword");
    });
  });
});
<script type="text/x-handlebars" data-template-name="userSetup">
  <div class='sidebar'>
    Sidebar
  </div>
  <div class='main'>
    Setup <br/>
    {{outlet}}
  </div>
</script>

边栏
设置
{{outlet}}
可以在此处找到完整的示例:

在Ember.js中,正确的方法是什么

编辑


在sly7_7的帮助下,我成功地把上面的小提琴演奏好了:。我所做的只是将所有内容从
userSetup
(模板、视图、路由)重命名为
setup
。但显然这不是一个解决方案(因为我也有appSetup)

根据您的评论示例,我想我已经完成了您想要的:

路由器代码:

App.Router.map(function(match){
  match('/').to('home');
  match('/about').to('about');
  match('/contributors').to('contributors', function(match){
    match('/').to('contributorsIndex');
    match('/:contributor_id').to('contributor', function(match){
      match('/').to('contributorIndex');
      match('/details').to('contributorDetail');
      match('/repos').to('contributorRepos');
    });
  });
});

可能是相关问题:

我发现了这个类似的小提琴()-当模板和路由匹配的名称在我的代码中出现时,插座似乎是“自动”连接的,并且似乎(!)当我的模板/视图被称为“设置”时它工作,当它被称为“用户设置”时它没有-臭虫?我担心我真的不明白你到底想要什么。你能更新你的问题吗,描述一下你希望哪个屏幕有哪些内容?我不知道你使用的是哪个版本的ember,但是如果是以前的,你应该只使用带下划线的模板名称。我使用的是Master最新的ember。我想要的其实很简单:让示例()工作-不改变名称的含义:)