And*_*der 6 typescript angular
我在模块中设置我的路由,我想设置默认路由,但它失败了
这是路由模块
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 }
];
Run Code Online (Sandbox Code Playgroud)
以上返回错误
LoginComponent; useAsD...' is not assignable to type 'Route[]'
Run Code Online (Sandbox Code Playgroud)
可能有什么不对
ER.*_*ARI 13
使用useAsDefault时,您需要在要首先显示的子路由上使用父路由和useAsDefault.所以,不需要使用AsDefault,你可以简单地给Login As Default Routes.And,因为我看到没有为Dashboard导入的组件,所以,
const appRoutes: Routes = [
{
path: '',
redirectTo: "/login",
pathMatch: 'full'
},
{ path: 'login', component: LoginComponent },
{ path: 'reset-password', component: ResetPasswordComponent },
{ path: '**', component: PageNotFoundComponent }
];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
15801 次 |
最近记录: |