我定义了一个延迟加载模块。
这是SettingsRoutingModule模块-
const routes: Routes = [
{
path: '',
component: SettingsStandaloneComponent,
children: [
{
path: '',
redirectTo: 'profile',
pathMatch: 'full'
},
{
path: 'profile',
component: SettingsProfileComponent
},
{
path: 'about',
component: SettingsAboutComponent
},
{
path: 'affiliations',
component: SettingsAffiliationsComponent
},
{
path: 'communication',
component: SettingsCommunicationComponent
},
{
path: 'notifications',
component: SettingsNotificationsComponent
},
{
path: 'proxies',
component: SettingsProxiesComponent
},
{
path: '**',
redirectTo: 'profile',
pathMatch: 'full'
}
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class SettingsRoutingModule { }
在AppRoutingModule模块中-
{ path: 'settings',
loadChildren: './settings/settings.module#SettingsModule',
canActivate: [AuthGuard],
},
在产品生产中,当访问网络时,我没有看到每个人都说应该出现的“chunk.js”。只有两个文件看起来像 - 0.34016a93d44e785b623a.js
在我的本地主机中,我只看到“settings-settings-module.js”
可以吗,或者这是否意味着我的模块并不懒惰?
最佳答案
由于 angular.json 中的此选项 "namedChunks": false
,您将不再看到命名 block ,而是将哈希值显示为文件名。这是由于 Angular/cli 最近的改进(不确定从何时开始)。
关于javascript - Angular 延迟加载 - 没有看到它正在工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54104119/