![](/img/trans.png)
[英]My Angular web app is routing through buttons as expected, but when I type the page path in the url, routing doesn't work. While hosted on firebase
[英]Routing in app with firebase doesn`t work correct
https://github.com/Wilkuuu/Biblio
在html i`中的Books組件中:
<a
routerLink="/books/{{book.id}}"
class="btn btn-secondary btn-sm">
<i class="fa fa-file"></i>
</a>
在app-routing中:
{ path: 'book/:id', component: BookDetailComponent }
在URL中我看到來自firebase的id,但路徑提供了我:
{ path: '**' , component: NotfoundComponent },
只需查看您的路線配置:
{ path: 'book/:id', component: BookDetailComponent }
你應該使用的路線是book/
而不是books/
routerLink="/books/{{book.id}}"
應該
routerLink="/book/{{book.id}}"
是的,正如安德烈提到的那樣,全能路線( path: '**'
的路線)應該是路線配置中的最后一條路線。
Ofc問題解決了。 {path:'**',component:NotfoundComponent}必須是最后一個。 Ty!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.