【问题标题】:aurelia/html repeat.for - redundant elementsaurelia/html repeat.for - 冗余元素
【发布时间】:2018-03-10 18:22:08
【问题描述】:

我有以下html(视图):

<li>
    <b>Institute:</b> Length: ${institutes.length}
    <ul>
        <li repeat.for="el of institutes">
        ${el.institute}: ${el.terminalCount}
        </li>
    </ul>
</li>

我在浏览器中看到以下内容:

如所见,数组 institutes 有 2 个元素,但在列表中我看到了 4 多行 - 具有空值。 它是什么?我该如何解决?

提前致谢。

【问题讨论】:

  • 你能在GistRun 中证明这一点吗?这是mine,它按预期工作。
  • 我们看到,institutions 的属性长度等于 2,而 for(el of Institutes) 产生一个由 6 个元素组成的序列。其中两个有属性 Institute 和 terminalCount 到底是什么?
  • chrome 有一个扩展,可以让你检查你的 aurelia 应用程序chrome.google.com/webstore/detail/aurelia-inspector/… 中发生的事情,很确定你会看到机构中还有其他东西。
  • 创建的海量似乎有问题。我已经更改了数组数据的来源并得到了正确的结果。

标签: aurelia repeat


【解决方案1】:

除了元素之外,您肯定在该数组上还有其他东西。否则它只是两个 LI 标签。

如果你看@source aurelia 模板中有许多转发器策略。取决于您要迭代的对象的类型。

如果你正在积极开发 aurelia 的东西,我建议你加入 official aurelia discourse 还有gitter channel

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 2018-06-26
    • 2017-06-12
    • 2021-05-05
    相关资源
    最近更新 更多