SAP Spartacus UI ConfigurableRoutesService router.resetConfig 的调用逻辑
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus UI ConfigurableRoutesService router.resetConfig 的调用逻辑
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在該 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 ConfigurableRoutesService router.resetConfig 的调用逻辑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么 SAP 电商云 Spartacu
- 下一篇: 为什么 SAP 电商云 Spartacu