美文网首页SAP
SAP Spartacus UI ConfigurableRou

SAP Spartacus UI ConfigurableRou

作者: 华山令狐冲 | 来源:发表于2021-11-25 07:52 被阅读0次

在该 service 的 init 方法里,有如下的代码调用:

protected configure(): void {
    // Router could not be injected in constructor due to cyclic dependency with APP_INITIALIZER:
    const router = this.injector.get(Router);
    router.resetConfig(this.configureRoutes(router.config));
  }

原因是因为 Angular route 数据类型里的 path 和 matcher 字段不能同时使用:

最后计算出的 route 信息里,path 都被赋上了对应的值,只有这些值才能被 Angular router 框架解析到。

有的路由信息比如 product,没有使用 path,而采用的 matchers,如下图所示:


注意字段名为 matchers,而 Angular router 框架 route 数据结构里的字段名为 matcher,因此我们需要 ConfigurableRoutesService,将 matchers 内的值转换成 router 框架接受的 matcher 字段。

转换后的结果如下图所示:


更多Jerry的原创文章,尽在:"汪子熙":


相关文章

网友评论

    本文标题:SAP Spartacus UI ConfigurableRou

    本文链接:https://www.haomeiwen.com/subject/szlhaltx.html