meteor - Meteor.js 中的区域产量

标签 meteor iron-router

在我的meteor.js应用程序中,有些页面有侧边菜单,有些页面没有。这是我的layout.html

<template name="layout">
<div class="container">
    {{> header}}
   <div id="main" class="col-md-3">
        {{> yield region="sidenavigation"}}
    </div>
    <div id="main" class="col-md-9">
        {{> yield}}
    </div>
</div>
</template>

假设我有一个有侧面菜单的 x 模板,和没有侧面菜单的 y 模板。当我渲染 x 模板时,一切都很好。但是当我渲染 y 模板时,因为它没有侧面菜单,所以内容会按预期推到右侧。我该如何解决这个问题?谢谢。

最佳答案

在要显示侧边菜单的模板或页面中使用 {{#contentFor region=''}}

例如。

<template name="yourtemplatename">
  {{#contentFor region="sidenavigation"}}
    ..
    ...
    ....
  {{/contentFor}}

</template>

示例https://github.com/EventedMind/meteor-building-an-application-with-meteor-and-iron-router

关于meteor - Meteor.js 中的区域产量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25559183/

相关文章:

meteor - meteor 收集更新中的狩猎错误

javascript - meteor.js 铁路由器 : prevent static template re-render and glitching?

javascript - 如何使用 Iron Router 获取 domain.com/keyword 中的 'keyword'

javascript - 铁路由器与流路由器

javascript - 使用 javascript 对象的 mongodb/meteor 集合查询

meteor - 如何管理同步到 Meteor 客户端缓存的数据?

javascript - meteor :删除帖子,并使用 _uihooks 为其他帖子设置动画

javascript - Meteor 中的 collection.insert 问题?

meteor - 多个 Meteor 应用程序、多个子域、共享数据库

animation - meteor #each : animate entry of new items