【问题标题】:Routing in Meteor with iron router to different templates使用铁路由器在 Meteor 中路由到不同的模板
【发布时间】:2016-05-10 15:20:01
【问题描述】:

我仍在学习 Meteor 的来龙去脉。我正在使用铁路由器并成功路由页面。我的路线所在的布局页面基本上是这样的。它们在标题和标题下加载,其中包含一些按钮:

<template name="layout">
  <div class="container">
    ... // some buttons here
    ... // more buttons
  </div>
  <h3>Header Title</h3>
  <div class container>
    {{> yield}}
  </div>
</template>

我已将布局模板作为默认模板:

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

如您所见,我的路线正在布局模板中加载,但有一个页面我想路由到一个完全空白的模板,但现在它在布局模板中。我可以让路线以某种方式转到不同的 {{> yield}} 标签吗?

【问题讨论】:

    标签: meteor


    【解决方案1】:

    您正在寻找路由控制器:

    http://iron-meteor.github.io/iron-router/#creating-route-controllers

    这将允许您在特定的一组路线上指定一个 layoutTemplate,而不是全局。然后,您可以为需要不同布局模板(以及其他东西)的不同路线集创建不同的组。

    【讨论】:

      猜你喜欢
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多