Angular编译器cli v.7.2.0抛出了:
属性“ runGuardsAndResolvers”的类型不兼容。类型“字符串”不可分配给类型“ RunGuardsAndResolvers”
设置runGuardsAndResolvers: 'always'导入到中的常量时AppRoutingModule。
当我runGuardsAndResolvers: 'always'在AppRoutingModule自己内部设置时,不会发生这种情况。
app-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { adminRouterConfig } from 'src/app/core/_routing/admin-router-config';
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{
path: '',
children: [
...adminRouterConfig
]
},
{ path: '**', redirectTo: '', pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes,
{ enableTracing: true }
)],
exports: [RouterModule]
})
export class AppRoutingModule { }
admin-router-config.ts
import { AuthGuard } from 'src/app/core/_guards/auth.guard';
export const adminRouterConfig = [
{
path: 'admin',
runGuardsAndResolvers: 'always',
canActivate: [AuthGuard],
children: [
...
]
}
];
qq_花开花谢_0
相关分类