Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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
Meteor 如何在主内容中呈现动态布局和静态布局_Meteor_Iron Router - Fatal编程技术网

Meteor 如何在主内容中呈现动态布局和静态布局

Meteor 如何在主内容中呈现动态布局和静态布局,meteor,iron-router,Meteor,Iron Router,我只是从来自余烬的流星开始。我拥有的是一个菜单,这些项目被渲染到maincontent布局中。现在我想在maincontent布局中有第二个菜单 示例:我单击导航栏中的人员,获得人员列表。现在我点击一个人,我得到了这个人的详细信息。导航仍然可见。这就是我迄今为止所做的工作 现在,我希望在person模板中有另一个菜单,其中包含todo、events等项 Router.configure({ layoutTemplate: 'layout' }); <template name="pe

我只是从来自余烬的流星开始。我拥有的是一个菜单,这些项目被渲染到maincontent布局中。现在我想在maincontent布局中有第二个菜单

示例:我单击导航栏中的人员,获得人员列表。现在我点击一个人,我得到了这个人的详细信息。导航仍然可见。这就是我迄今为止所做的工作

现在,我希望在person模板中有另一个菜单,其中包含todo、events等项

Router.configure({
 layoutTemplate: 'layout'
});


<template name="person">

  //shows the details of that one person

</template>

<template name="events">

 //shows the events of that one person

</template>

<template name="todos">

  //shows the todos of that one person

</template>

<template name="personlayout">

   <a href="{{pathFor 'person'}}">persondetails</a>
   <a href="{{pathFor 'todos'}}">todos</a>
   <a href="{{pathFor 'events'}}">events</a>

</template>
Router.configure({
layoutTemplate:“布局”
});
//显示一个人的详细信息
//显示一个人的事件
//显示一个人的待办事项
只要显示人员模板,obove的3个链接就应该始终可见。导航到localhost时类似:3000/人/5403789845ef834ed58ae745


那么,如何在personlayout模板中呈现person、todos或events模板呢?

首先,您需要在
personlayout
中定义
收益率

<template name="personLayout">
   {{yield}}
   {{yield "persons"}}
   {{yield "todos"}}
   {{yield "events"}}
</template>
使用contentFor


从这里开始的一切都将是`个人布局'{{>yield}

{{>contentFor region=“person”template=“person”} {{>contentFor region=“todos”template=“todos”} {{>contentFor region=“todos”template=“events”}

在iron router中,为所需路径设置layoutTemplate。将使用它而不是默认模板。假设您希望链接x或y使用完全不同的结构化模板。谢谢。但这似乎只适用于一级深嵌套模板。我需要的是一个布局中的布局。我有一个布局模板,其中包含顶部导航,并且始终可见。在该导航中,我有多个菜单项。其中之一是人员模板。其中有一份人员名单。现在当我亲自/123时,应该有另一个菜单。它包含诸如persondetails(加载时可见)、persontodos、personevents等项。。。例如,当我点击TODO时,我想为那个人显示TODO。个人细节、事件。。。仅在单击时显示。
Router.route('/post/:_id', function () {
  this.layout('personLayut');

  // render the Post template into the "main" region
  // {{> yield}}
  this.render('Post');

  // render the person template into the yield region named "person" 
  // {{> yield "persons"}}
  this.render('person', {to: 'person'});

  // render the todos template into the yield region named "todos" 
  // {{> yield "todos"}}
  this.render('todos', {to: 'todos'});
});
<template name="Page">
  <p>
    EVerything from here is going to `personLayout` {{> yield}}
  </p>

  {{> contentFor region="person" template="person"}}

  {{> contentFor region="todos" template="todos"}}

  {{> contentFor region="todos" template="events"}}

</template>