html - Aurelia 将#hash 替换为动态创建的 anchor 标记

标签 html twitter-bootstrap aurelia

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

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

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

Route not found: /${section.id}

我怎样才能克服这个问题?

最佳答案

您的 href 中有错字。您没有关闭 {。因此,您的 anchor 按原样生成,没有 section.id 值绑定(bind)。将其更改为:

<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 )

关于html - Aurelia 将#hash 替换为动态创建的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46326054/

相关文章:

Aurelia - 在自定义元素准备/绑定(bind)之前查看渲染

javascript - Aurelia - 为类实现三元并获取缺少的属性名称

php - 如何设置 HTML 文件字段的值?

javascript - 刷新javascript中的时间

html - Bootstrap 导航栏调整大小

php - 我如何用 <a> 发送参数以在 smarty & Php 中设置查询 MySQL

javascript - Twitter 按钮不会出现在 Firefox 上

html - 将鼠标悬停在 div 上,该特定的 div 会展开,而其他两个 div 会缩小

javascript - html5验证和JS

javascript - 遍历数组时为 "[__array_observer__: ModifyArrayObserver]"