【问题标题】:Yield doesn't display inside layout产量不显示在布局内
【发布时间】:2013-11-07 13:53:21
【问题描述】:

再次感谢这款出色的路由器。我遇到了产量问题,没有在应有的地方屈服。像大多数错误一样,这个错误可能是在椅子和键盘之间的某个地方造成的,因此非常感谢您的帮助!

我的模板 html 非常简单。

<body>
  {{> layout}}
</body>

<template name='layout>
<!--wrapper tags -->
  {{> nav}}
   <!--more wrapper tags -->  
     {{yield}}
   <!--close wrapper tags -->  
   {{> footer}}
 <!--close wrapper tags -->  
</template>

渲染时,我看到(按顺序): 导航 > 页脚 > 导航 > 产量 > 页脚

我尝试将所有包装器以及{{&gt;nav}}{{&gt;footer}} 放入主体标签中,在布局模板中只留下{{yield}}。当我这样做时,我得到 NAV > FOOTER > YIELD。

在这两种情况下,我的路由器 js 是相同的:

if (Meteor.isClient) {

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

Router.map(function () {
  this.route('home', {
    path: '/',
    template: 'home',
    after: function () {
      addLabel(this.path);
    }
  })
//more routes
});
}

我确信这是我所做的很愚蠢的事情,但如果你能提供任何帮助,我将不胜感激。

提前致谢, 分贝

【问题讨论】:

    标签: meteor meteorite iron-router


    【解决方案1】:

    从 body 标签中移除 {{> 布局}}。

    <body>
      <!-- no template here, router will add layout automatically -->
    </body>
    
    <template name='layout'>
    <!--wrapper tags -->
      {{> nav}}
       <!--more wrapper tags -->  
         {{yield}}
       <!--close wrapper tags -->  
       {{> footer}}
     <!--close wrapper tags -->  
    </template>
    

    而您在

    【讨论】:

    • 对此有何补充说明?
    猜你喜欢
    • 1970-01-01
    • 2018-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多