【问题标题】:Aurelia replaces # hash with / for dynamically created anchor tagsAurelia 将 # hash 替换为 / 用于动态创建的锚标签
【发布时间】:2018-03-01 18:01:23
【问题描述】:

我正在尝试在我的 Aurelia 应用中实现 BootStrap Scroll Spy。我有以下动态创建的锚标签:

<div class="nav-link au-animate" repeat.for="section of variant.sections">
    <a href="#${section.id}">${section.title}</a>
</div>

但是锚标签不起作用,我收到以下控制台错误:

Route not found: /${section.id}

我该如何解决这个问题?

【问题讨论】:

    标签: html twitter-bootstrap aurelia


    【解决方案1】:

    您的href 中有错字。您没有关闭{。因此,您的锚点按原样生成,没有 section.id 值绑定。改成:

    <div class="nav-link au-animate" repeat.for="section of variant.sections">
        <a href="#${section.id}">${section.title}</a>
    </div>
    

    我添加了gist

    (Embedded result window without nav collapse)

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 2013-05-26
    • 2023-03-10
    • 1970-01-01
    • 2011-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多