【问题标题】:Each clause is not working after Template Name change模板名称更改后每个子句都不起作用
【发布时间】:2016-01-09 02:03:06
【问题描述】:

我不明白为什么在每个子句周围添加模板“simple-todos”后它们不起作用?!

<template name="simple-todos">
<head>
  <title>Todo List</title>
</head>

<body>
<div class="row">
    <header>
        <h1>Todo List</h1>
        {{> addObjects}}
    </header>
  <ul>
      {{#each tasks}}
          {{> task}}
      {{/each}}
  </ul>
</div>
</body>
</template>

<template name="task">
    <li class="{{#if checked}}checked{{/if}}">
        <button class="delete">&times;</button>
        <input type="checkbox" checked="{{checked}}" class="toggle-checked" />
        <span class="text">{{text}}</span>
        <span class="text">{{createdAt}}</span>
    </li>
</template>

当我不使用模板名称“simple-todos”时,我直接成为数据库中的值...

感谢您的帮助...

【问题讨论】:

    标签: html meteor each clause


    【解决方案1】:

    您不能将headbody 标签放在 Meteor 模板中,请改用此方法:

    HTML

    <!-- HEAD and BODY must be top level tags -->
    
    <head>
      <title>Todo List</title>
    </head>
    
    <body>
      {{> simpleTodos}}
    </body>
    
    <template name="simpleTodos">
      <div class="row">
        ...
      </div>
    </template>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-16
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      • 2022-07-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多