我在模块中设置我的路由,我想设置默认路由,但是失败
这是路由模块
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent, useAsDefault:true }, //returns an error
{
path: 'dash',
redirectTo:"dashboard"
},
{ path: 'reset-password', component: ResetPasswordComponent },
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
上面的返回错误
LoginComponent; useAsD...' is not assignable to type 'Route[]'
可能是什么问题
使用useAsDefault时,您需要具有父路由,并且要先出现的子路由具有useAsDefault。因此,不需要useAsDefault,您可以简单地将Login作为默认路由提供。正如我所见,Dashboard没有导入的组件,因此,
const appRoutes: Routes = [
{
path: '',
redirectTo: "/login",
pathMatch: 'full'
},
{ path: 'login', component: LoginComponent },
{ path: 'reset-password', component: ResetPasswordComponent },
{ path: '**', component: PageNotFoundComponent }
];
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句