2017-09-20 38 views
1

我试图在我的Aurelia应用中实现BootStrap Scroll Spy。我有以下动态创建锚标记:Aurelia用#替换#为动态创建的锚标记

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

我怎样才能解决这个问题?

回答

0

您在您的href中有错字。您没有关闭{。因此,您的定位符是按原样生成的,不需要绑定值。更改为:

<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

+0

对不起,是我不好,那竟是我的问题一个错字。 – Viqas

+0

@Viqas没关系。但这个要点仍然有效。你有没有像这样配置你的路由器? https://stackoverflow.com/a/38668108/3082296和http://aurelia.io/hub.html#/doc/article/aurelia/router/latest/router-configuration/2 – adiga

+0

问题是只有当你'继续'/'。当在任何其他的URL上,你将被重定向到'/'加上'#hash-you-linked-to' – powerbuoy