0

假设我们正在从模块 A 延迟加载模块 B。例如:

// routes for module A

const routes: Routes = [ 
  { path: '', loadChildren: './pages/B/B.module#BModule'}
]
// routes for module B

const routes: Routes = [ 
  { path: '', component: 'BComponent'}
]

我的问题是我应该在哪里使用组件/模块 B 的解析。在 A 或 B 的路线内?哪个是正确/更好的方法?

4

1 回答 1

1

我会在我的延迟加载模块中执行此操作。在向 Mod A 添加解析时,将等待解析完成,然后才会开始下载该惰性路由所需的模块。

另一项建议是,如果您需要使用 resolve(并且如果需要相当长的时间才能完成),请尝试预取该惰性路由。这可能会大大减少您的时间。

于 2019-10-31T08:46:45.490 回答