【问题标题】:how to load the modules in angular 11如何以角度 11 加载模块
【发布时间】:2021-04-24 10:18:29
【问题描述】:

我有一个很大的疑问。调用或加载模块的方式是什么?

考虑到我有 3 个模块(模块 1、模块 2、模块 3),它们稍后会有自己的组件和路由

在路线中(延迟加载)?

还是导入到组件中?

也许他们是不同的东西,我希望他们能为我澄清。谢谢

【问题讨论】:

    标签: angular typescript angular11


    【解决方案1】:

    要延迟加载模块,您可以配置如下路由。

    const routes: Routes = [
      {
        path: 'module1',
        loadChildren: () => import('./module1/module1.module').then(m => m.Module1Module)
      },
      {
        path: 'module2',
        loadChildren: () => import('./module2/module2.module').then(m => m.Module2Module)
      }
    ];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-07
      相关资源
      最近更新 更多