Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度懒散加载具有相同起始路径的页面_Angular_Lazy Loading_Angular Lazyloading - Fatal编程技术网

Angular 角度懒散加载具有相同起始路径的页面

Angular 角度懒散加载具有相同起始路径的页面,angular,lazy-loading,angular-lazyloading,Angular,Lazy Loading,Angular Lazyloading,我有一个相当大的项目,为了减少捆绑包的大小,我决定将其划分为多个具有延迟负载的模块。这是我的应用程序路由 const routes: Routes = [ { path: 'profile', loadChildren: () => import('./pages/public/freelancer-profile/freelancer-profile.module').then(m => m.FreelancerProfileModule) }, {

我有一个相当大的项目,为了减少捆绑包的大小,我决定将其划分为多个具有延迟负载的模块。这是我的应用程序路由

const routes: Routes = [
  {
    path: 'profile',
    loadChildren: () => import('./pages/public/freelancer-profile/freelancer-profile.module').then(m => m.FreelancerProfileModule)
  },
  {
    canActivate: [LoginGuardService],
    path: 'panel',
    loadChildren: () => import('./pages/private/private.module').then(m => m.PrivateModule)
  },
  {
    path: '',
    loadChildren: () => import('./pages/public/public.module').then(m => m.PublicModule)
  },
  {
    path: '',
    loadChildren: () => import('./pages/landing/landing.module').then(m => m.LandingModule)
  },
  {
    path: '',
    loadChildren: () => import('./pages/public/logging/logging.module').then(m => m.LoggingModule)
  },
  {
    path: '**',
    redirectTo: '404',
  }
];
我希望仅当页面路径在其模块中时,才能加载landing.module,但发生的情况如下: 如果页面路径位于logging.module上,则也会下载public.module和landing.module块。 我怎样才能解决这个问题? 我在想,是否有一种方法可以检查URL并仅在URL与模块中的一个路径匹配时下载模块


注意:我无法更改URL和添加前缀来避免这种情况,因为页面是通过搜索引擎编制索引的。

为什么有些路径也是空的?行吗?不行。在不加载模块的情况下,您如何知道模块中添加了哪些路径?您应该重新考虑模块体系结构,将一个路径前缀映射到一个模块。路由配置中的某些路径属性为空。为什么不为他们指定路线?@ClusterH他们在路线中有相同的前缀child路线不同,例如,我在第一个模块中有/home/dashboard,在第二个模块中有/search和/panel,我无法将它们分开prefix@Clashsoft在生产项目中,你们不能添加无用的前缀来划分区块,因为seo和在单个块中加载所有登录页将影响页面速度。我正在寻找一种方法,当用户访问单个页面时,不要加载所有的登录页面