Ionic 4 / Angular Routing: ERROR Error: Uncaught (in promise): Error: Cannot find 'EventHomePageModule' in './home/home.module'
Ionic 4 / Angular Routing: ERROR Error: Uncaught (in promise): Error: Cannot find 'EventHomePageModule' in './home/home.module'
我正在试用昨天发布的 Ionic 4 Beta 15。
这是我的 AppRoutingModule
const routes: Routes = [{
path : '',
loadChildren : './tabs/tabs.module#TabsPageModule'
/*
}, {
path : 'event/:id',
loadChildren : './event/event.module#EventModule'
}, {
path : 'ngo/:id',
loadChildren : './ngo/ngo.module#NgoModule'
*/
}, {
path : 'volunteer/:id',
loadChildren : './volunteer/volunteer.module#VolunteerModule'
}];
@NgModule({
imports: [RouterModule.forRoot(routes, { enableTracing: true })],
exports: [RouterModule]
})
export class AppRoutingModule {}
如上面的代码所示,如果我注释掉 3 条路径中的任意 2 条,Event
、Ngo
或 Volunteer
,路由工作正常。
但是当我同时启用这两条路径中的任何一条时,出现以下错误:
Error: Cannot find 'NgoHomePageModule' in './home/home.module'
at checkNotEmpty (core.js:5007)
at core.js:4984
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:3820)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3811)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at checkNotEmpty (core.js:5007)
非政府组织或志愿者随机发生 ionic serve
路由在我的 VolunteerModule
const routes = [{
path : 'home',
loadChildren : './home/home.module#VolunteerHomePageModule'
}, {
path : 'event',
loadChildren : './event/event.module#VolunteerEventPageModule'
}, {
path : 'achievement',
loadChildren : './achievement/achievement.module#VolunteerAchievementPageModule'
}, {
path : '',
redirectTo : 'home'
}];
路由在我的 NgoModule
const routes = [{
path : 'home',
loadChildren : './home/home.module#NgoHomePageModule'
}, {
path : 'upcoming',
loadChildren : './upcoming /upcoming.module#NgoUpcomingPageModule'
}, {
path : 'past',
loadChildren : './past/past.module#NgoPastPageModule'
}, {
path : 'volunteer',
loadChildren : './volunteer/volunteer.module#NgoVolunteerPageModule'
}, {
path : '',
redirectTo : 'home'
}];
我的文件夹结构:
▾ ngo/
▸ home/
▸ past/
▸ upcoming/
▸ volunteer/
[ ]ngo.module.spec.ts
[ ]ngo.module.ts
▸ tabs/
▾ volunteer/
▸ achievement/
▸ event/
▸ home/
[ ]volunteer.module.spec.ts
[ ]volunteer.module.ts
[ ]app-routing.module.ts
更新 1:
将回购上传到
https://gitlab.com/saiy2k/ionic.4-beta.15-routing-issue
我做错了什么?请帮忙。
让它工作,但令人难以置信的解决方案。
以唯一名称重命名功能的子文件夹,如下:
▾ ngo/
▸ home/ --> nhome/
▸ past/ --> npast/
▸ upcoming/ --> nupcoming/
▸ volunteer/ --> nvolunteer/
[ ]ngo.module.spec.ts
[ ]ngo.module.ts
▸ tabs/
▾ volunteer/
▸ achievement/ --> vachievement/
▸ event/ --> vevent/
▸ home/ --> vhome/
[ ]volunteer.module.spec.ts
[ ]volunteer.module.ts
[ ]app-routing.module.ts
此更改解决了该问题。但我不明白为什么!有什么解释吗?
同样推送到https://gitlab.com/saiy2k/ionic.4-beta.15-routing-issue/tree/fix
遇到同样的问题,但我只是停止 ionic serve
并重新执行它。
我正在试用昨天发布的 Ionic 4 Beta 15。
这是我的 AppRoutingModule
const routes: Routes = [{
path : '',
loadChildren : './tabs/tabs.module#TabsPageModule'
/*
}, {
path : 'event/:id',
loadChildren : './event/event.module#EventModule'
}, {
path : 'ngo/:id',
loadChildren : './ngo/ngo.module#NgoModule'
*/
}, {
path : 'volunteer/:id',
loadChildren : './volunteer/volunteer.module#VolunteerModule'
}];
@NgModule({
imports: [RouterModule.forRoot(routes, { enableTracing: true })],
exports: [RouterModule]
})
export class AppRoutingModule {}
如上面的代码所示,如果我注释掉 3 条路径中的任意 2 条,Event
、Ngo
或 Volunteer
,路由工作正常。
但是当我同时启用这两条路径中的任何一条时,出现以下错误:
Error: Cannot find 'NgoHomePageModule' in './home/home.module'
at checkNotEmpty (core.js:5007)
at core.js:4984
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
at Object.onInvoke (core.js:3820)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
at zone.js:872
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:3811)
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
at checkNotEmpty (core.js:5007)
非政府组织或志愿者随机发生 ionic serve
路由在我的 VolunteerModule
const routes = [{
path : 'home',
loadChildren : './home/home.module#VolunteerHomePageModule'
}, {
path : 'event',
loadChildren : './event/event.module#VolunteerEventPageModule'
}, {
path : 'achievement',
loadChildren : './achievement/achievement.module#VolunteerAchievementPageModule'
}, {
path : '',
redirectTo : 'home'
}];
路由在我的 NgoModule
const routes = [{
path : 'home',
loadChildren : './home/home.module#NgoHomePageModule'
}, {
path : 'upcoming',
loadChildren : './upcoming /upcoming.module#NgoUpcomingPageModule'
}, {
path : 'past',
loadChildren : './past/past.module#NgoPastPageModule'
}, {
path : 'volunteer',
loadChildren : './volunteer/volunteer.module#NgoVolunteerPageModule'
}, {
path : '',
redirectTo : 'home'
}];
我的文件夹结构:
▾ ngo/
▸ home/
▸ past/
▸ upcoming/
▸ volunteer/
[ ]ngo.module.spec.ts
[ ]ngo.module.ts
▸ tabs/
▾ volunteer/
▸ achievement/
▸ event/
▸ home/
[ ]volunteer.module.spec.ts
[ ]volunteer.module.ts
[ ]app-routing.module.ts
更新 1: 将回购上传到 https://gitlab.com/saiy2k/ionic.4-beta.15-routing-issue
我做错了什么?请帮忙。
让它工作,但令人难以置信的解决方案。
以唯一名称重命名功能的子文件夹,如下:
▾ ngo/
▸ home/ --> nhome/
▸ past/ --> npast/
▸ upcoming/ --> nupcoming/
▸ volunteer/ --> nvolunteer/
[ ]ngo.module.spec.ts
[ ]ngo.module.ts
▸ tabs/
▾ volunteer/
▸ achievement/ --> vachievement/
▸ event/ --> vevent/
▸ home/ --> vhome/
[ ]volunteer.module.spec.ts
[ ]volunteer.module.ts
[ ]app-routing.module.ts
此更改解决了该问题。但我不明白为什么!有什么解释吗?
同样推送到https://gitlab.com/saiy2k/ionic.4-beta.15-routing-issue/tree/fix
遇到同样的问题,但我只是停止 ionic serve
并重新执行它。