【问题标题】:Meteor - Error: Expected template or null, found: falseMeteor - 错误:预期模板或空,发现:假
【发布时间】:2018-01-23 23:57:23
【问题描述】:

我正在尝试实现自己的标签,每个标签都有自己的内容。默认选择的选项卡是选项卡 1。它加载 html 内容和模板就好了。当我尝试切换到其他两个选项卡时,我收到以下错误消息:

错误:预期模板或空,发现:假

在这种情况下,在选项卡 1 中呈现的模板与在选项卡 3 中呈现的模板相同。在选项卡 1 中工作正常,在选项卡 3 中我收到错误消息。

{{#if isSeletedTab 1}}
  <div class="col-sm-12  horizontal-list">
    <div class="new-store-card">
      <img src='./img/add.png' />
      <br/>
      <span class="new-store-text">Add a new</span>
      <br/>
      <span class="new-store-text">store</span>
    </div>
  {{#each store in stores}}
      <div class="store-card-container">
        {{#if isSelectedStore store.name}}
        <div class="edit-store-button">
          <img src="./img/edit.png" class="edit-store-button-icon"/>
        </div>
        {{/if}}
        <div class="store-card" id={{store.name}} style="{{#unless isSelectedStore store.name}}opacity: 0.3;{{/unless}}">
          <h5 class="store-card-name" id={{store.name}}>{{store.name}}</h5>
          <span class="store-card-id" id={{store.name}}>{{store.externalId}}</span>
        </div>
      </div>
  {{/each}}
  </div>
  {{> users}}
{{else isSeletedTab 2}}
  {{> roles}}
{{else isSeletedTab 3}}
  {{> users}}
{{/if}}

【问题讨论】:

  • 你能告诉我们usersroles模板的html代码吗?请同时显示标签&lt;template name="XXXX"&gt;&lt;/template&gt;。顺便说一句,默认情况下,您不能在 {{else}} 中使用条件,也不能在 if 中放置多个 else。 (只是说,也许你有特殊的帮手)

标签: meteor meteor-blaze


【解决方案1】:

您以错误的方式使用{{if}}{{else}}。您不能在 else 中使用条件,并且 Blaze 中没有 else if

你的代码应该是这样的:

{{#if isSeletedTab 1}}
    {{> users}}
{{else}}
    {{#if isSeletedTab 2}}
        {{> roles}}
    {{else}}
        {{#if isSeletedTab 3}}
            {{> users}}
        {{/if}}
    {{/if}}
{{/if}}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-19
    • 1970-01-01
    • 2015-05-08
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 2019-04-26
    相关资源
    最近更新 更多