[英]Cannot match any routes angular
I am new to angular router, please take a look at the following code; 我是角度路由器的新手,请看下面的代码;
export const appRoutes: Routes = [{
path: '',
component: GridComponent,
outlet: 'center'
},{
path: 'login',
component: LoginComponent,
outlet: 'center'
}];
@NgModule({
imports: [RouterModule.forRoot(appRoutes, { useHash: true })],
exports: [RouterModule]
})
export class AppRoutingModule { }
app.html
--------
<header></header>
<router-outlet name="center"></router-outlet>
<footer></footer>
When I hit http://localhost:59050/#/login
I get the following error Cannot match any routes. URL Segment: 'login'
当我点击
http://localhost:59050/#/login
,出现以下错误Cannot match any routes. URL Segment: 'login'
Cannot match any routes. URL Segment: 'login'
but when I hit http://localhost:59050/#/
it shows the gridcomponent. Cannot match any routes. URL Segment: 'login'
但是当我点击http://localhost:59050/#/
它显示了gridcomponent。 I have also used and unused <base href="/" >
. 我还使用和未使用
<base href="/" >
。 Any help is greatly appreciated. 任何帮助是极大的赞赏。
卸下outlet: 'center'
如果不使用辅助路线,则不需要outlet: 'center'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.