我有一个离子角项目,并且在app.component.html中有离子路由器出口,可以重定向到教师页面
app-routing.module.ts中的路由
const routes: Routes = [
{
path: '',
redirectTo: 'teacher',
pathMatch: 'full'
},
{
path: 'login',
component: LoginComponent
},
{
path: 'teacher',
loadChildren: () => import('./pages/teacher/teacher.module').then(m => m.TeacherPageModule)
},
{
path: 'admin',
loadChildren: () => import('./pages/admin/admin.module').then(m => m.AdminPageModule)
}
];
在教师页面中,我重定向到课程页面
teacher-routing.module.ts
const routes: Routes = [
{
path: '',
redirectTo: 'classes',
},
{
path: 'classes',
component: ClassesComponent
}
];
我想在教师页面上显示课程页面
teacher.page.html
<ion-header>
<ion-toolbar>
<ion-title>teacher</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-router-outlet></ion-router-outlet> //<< classes page in here
</ion-content>
但是它仅显示课程页面的内容,而不执行教师页面。
答案 0 :(得分:0)
似乎我还没有在Route中将“ loadChildren”路由声明为“类”。像这样:
{
path: 'classes',
loadChildren: () => import('./pages/classes/classes.module').then(m => m.ClassesPageModule)
}
注意:此组件仅应与Angular项目一起使用。对于香草或Stencil JavaScript项目,请使用
ion-router
和ion-route
。