...
path: ':category/:page',
...
<a [routerLink]="[category.attributes.alias-name, 1]">
{{category.attributes.name}} </a>
第一個參數是NaN。我該如何解決它?routerlink接受字符串PARAMS在瀏覽器routerLink的
...
path: ':category/:page',
...
<a [routerLink]="[category.attributes.alias-name, 1]">
{{category.attributes.name}} </a>
第一個參數是NaN。我該如何解決它?routerlink接受字符串PARAMS在瀏覽器routerLink的
正如Bougarfaoui薩爾瓦多houcine指出,表達category.attributes.alias-name
是interprete作爲substration。並減去undefined
= Nan
。 所以,儘量使用此代碼擺脫你的錯誤
<a [routerLink]="[category.attributes['alias-name'], '1']">
這可能會實現:
<a [routerLink]="[category.attributes.alias-name, '1']">
試試這個:
<a [routerLink]="[category.attributes['alias-name'], '1']">
雖然這段代碼可能會回答這個問題,但提供關於如何解決問題和/或爲什麼解決問題的附加背景可以提高答案的長期價值。 –
我的意思是category.attributes.alias名是NaN在瀏覽器查詢網址 – denqxotl
你什麼時候加''
參數應該只是字符串values.if URL更新像http://localhost8201/category/page=1然後你可以從激活的路線 – Vignesh