這是我的錯誤:角度重新路由到首頁不起作用?
core.es5.js:1020 ERROR Error: Uncaught (in promise):
Error: Cannot match any routes. URL Segment: 'home'
這是從view.html代碼:
<div class="container">
This is the main app;
<a routerLink="second">Click to go to second</a>
<a routerLink="third">Click to go to third</a>
<a routerLink="app">Go to Home</a>
<router-outlet></router-outlet>
</div>
這是我的目標,其中包括路徑到家庭和其他路徑的陣列。到家的路徑是正確的,因此我不明白爲什麼每次點擊它時彈出錯誤。
const appRoutes: Routes=[
{path:'second', component:SecondComponent},
{path:'third', component:ThirdComponent},
{path:'', redirectTo:'./app', pathMatch:'full'},
]
當我點擊第三和第二個組件url時,一切正常。
注意:當我點擊家庭組件時,我想隱藏第二個和第三個組件。
您已經使用'routerLink =「home」',但沒有爲它創建路由。這樣做並檢查。 – abhig10
我改變了它,但事情保持不變。我只想顯示其他組件正在「擦除」的主頁。我怎樣才能做到這一點? – masterach
任何錯誤更改?如果沒有,請將'Go to Home'更改爲'Go to Home'並檢查。 – abhig10