当我从13角升级到14角后,我的角度路由出现了问题。我得到了以下错误:
*Uncaught Error: Uncaught (in promise): Error: NG04014: Invalid configuration of route 'homepage/'. One of the following must be provided: component, loadComponent, redirectTo, children or loadChildren*App.routing.ts
export const routes: Routes = [
{ path: '', redirectTo: 'homepage', pathMatch: 'full'},
{
path: 'homepage',
loadChildren: () =>
import('src/app/homepage/homepage-component/homepage.module').then(m => m.HomepageModule),
canActivate: [AuthGuard]
},
{
path: 'sales',
loadChildren: () =>
import('src/app/reports/sales-component/sales.module').then(m => m.HomepageModule),
canActivate: [AuthGuard]
},我尝试添加组件、加载组件等到路由中,因为错误是这样说的,但是加载子程序不会按预期工作。我用错了loadChildren吗?
发布于 2022-09-14 15:23:30
我认为这可能与下面的剧变有关。来源
PR #45176 Route.pathMatch的类型现在更加严格。使用pathMatch的位置可能需要更新,以具有显式的路由/路由类型,这样TypeScript就不会将该类型推断为字符串。
下面我试着看看它是否能解决你的问题:
export const routes: Routes = [
{
path: 'homepage',
loadChildren: () =>
import('src/app/homepage/homepage-component/homepage.module').then(m => m.HomepageModule),
canActivate: [AuthGuard]
},
{
path: 'sales',
loadChildren: () =>
import('src/app/reports/sales-component/sales.module').then(m => m.HomepageModule),
canActivate: [AuthGuard]
},
{
path: '',
redirectTo: '/homepage',
pathMatch: 'full',
}https://stackoverflow.com/questions/73718171
复制相似问题