离子选项卡应用程序在添加新选项卡时抛出错误
Ionic tab app throws error on new tab add
我正在尝试在我现有的 Ionic 应用程序中添加选项卡:
目录结构:
- src/pages/admin/dashboard
- src/pages/admin/tabs
- ..../tabs/ tabs.module.ts , tabs.page.html , tabes.page.ts , tabs.router.module.ts
tabs.module.ts代码:
import { DashboardPage } from '../dashboard/dashboard.page';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
TabsPageRoutingModule,
DashboardPage
],
declarations: [TabsPage]
})
export class TabsPageModule {}
tabs.router.module.ts代码:
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'dashboard',
outlet: 'dashboard',
loadChildren: '../dashboard/dashboard.module#DashboardPageModule'
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}
根据错误消息尝试了所有来源谷歌其更改
但仍然坚持以下错误消息:
core.js:12501 ERROR Error: Uncaught (in promise): Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
- 应用程序环境 ionic 4
感谢任何帮助或提示
您的问题在您的错误代码中:
Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'.
在 tabs.module.ts 中,您需要导入 PageModule 而不是页面本身。
所以将 DashboardPage 更改为 DashboardPageModule.
我正在尝试在我现有的 Ionic 应用程序中添加选项卡:
目录结构:
- src/pages/admin/dashboard
- src/pages/admin/tabs
- ..../tabs/ tabs.module.ts , tabs.page.html , tabes.page.ts , tabs.router.module.ts
tabs.module.ts代码:
import { DashboardPage } from '../dashboard/dashboard.page';
@NgModule({
imports: [
IonicModule,
CommonModule,
FormsModule,
TabsPageRoutingModule,
DashboardPage
],
declarations: [TabsPage]
})
export class TabsPageModule {}
tabs.router.module.ts代码:
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: 'dashboard',
outlet: 'dashboard',
loadChildren: '../dashboard/dashboard.module#DashboardPageModule'
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TabsPageRoutingModule {}
根据错误消息尝试了所有来源谷歌其更改 但仍然坚持以下错误消息:
core.js:12501 ERROR Error: Uncaught (in promise): Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
Error: Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'. Please add a @NgModule annotation.
- 应用程序环境 ionic 4
感谢任何帮助或提示
您的问题在您的错误代码中:
Unexpected directive 'DashboardPage' imported by the module 'TabsPageModule'.
在 tabs.module.ts 中,您需要导入 PageModule 而不是页面本身。
所以将 DashboardPage 更改为 DashboardPageModule.