javascript - Angular 延迟加载 - 没有看到它正在工作

标签 javascript angular typescript lazy-loading

我定义了一个延迟加载模块。

这是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/

相关文章:

angular - docker cloud上Angular 2上的net::ERR_CONTENT_LENGTH_MISMATCH

html - CSS Angular 简单形式在 Firefox 上被破坏

angular - 安装失败 'cordova-plugin-firebase' : CordovaError: Using "requireCordovaModule" to load non-cordova

typescript - 重叠类型的类型定义

javascript - Angular:无法导入 Sequelize

javascript - 如果 UUID 与字符串(autoIncrement)匹配,我如何移动到数组中的下一个项目?

javascript - 为什么暂停图标未在JS中显示

javascript - Q函数链接

javascript - 如何为只读 SlickGrid 单元格提供与可编辑单元格不同的背景?

node.js - 为什么人们将 typescript 的类型作为依赖项存储在 package.json(而不是 devDep)中?