angular - Angular 的子路由不能工作
问题描述
有人可以帮助我吗,我被困在 6 条儿童路线中。我的角度子路由无法在延迟负载下工作。
这是我的应用程序路由模块
import { NgModule } from '@angular/core';
import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
const routes: Routes = [
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{
path: 'master',
loadChildren: './modules/master/master.module#MasterModule'
},
];
@NgModule({
imports: [RouterModule.forRoot(routes, {
// preload all modules; optionally we could
// implement a custom preloading strategy for just some
// of the modules (PRs welcome )
preloadingStrategy: PreloadAllModules
})],
exports: [ RouterModule ]
})
export class AppRoutingModule { }
然后,这是我的主路由模块
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DokterComponent } from './dokter/dokter.component';
import { MasterComponent } from './master.component';
const routes: Routes = [
{
path: '',
component: MasterComponent
children: [
{ path: "", component: DokterComponent, pathMatch: "full" },
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class MasterRoutingModule { }
当我尝试访问/master/dokter 时,没有错误消息,但无法加载dokterComponent。感谢您的关注。
解决方案
推荐阅读
- calculator - 为什么我的 PHP 计算器在在数字字段中输入字母后不计算错误消息?
- selenium-chromedriver - 如何通过 Selenium 4 运行特定的浏览器?
- r - R 停止将 chr 转换为因子变量
- printing - 是否有任何云打印到文件的解决方案?
- android - 如何在现代环境中构建 android 内核
- flutter - 如何使用 Navigator 将数据(base64 - 字符串)传递到 Flutter 中的上一个屏幕?
- java - WebLogic 10.3.4 通配符证书导入
- python - Colaboratory 中的 ModuleNotFoundError
- php - 带参数的自定义帖子分页 - 404
- python - Flask App 在后台 ps aux /usr/bin/python3 中的第二个进程是什么?