我正在尝试实现 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 .
关于html - Aurelia 将#hash 替换为动态创建的 anchor 标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46326054/