2017-09-20 55 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