My Analysis

I set a breakpoint in function generateUrlPart in file Spartacus-core.js:

Angular里routerLink指令实际url的生成逻辑

For every path stored in routeConfig.paths, this function evaluates if route parameter passed by developers in can match ALL.

Angular里routerLink指令实际url的生成逻辑

Since I only specify “code” in my custom component template html,

Angular里routerLink指令实际url的生成逻辑

the evaulation will fail of course, as no counterpart exists for another parameter “name”:

Angular里routerLink指令实际url的生成逻辑

solution

After I add the other necessary route parameter nameForUrl: ‘Jerry’ in my html:

Angular里routerLink指令实际url的生成逻辑

this time function generateUrlPart can return the expected result:

Angular里routerLink指令实际url的生成逻辑

This time route works since the static url is generated successfully and contained in the rendered html.

Angular里routerLink指令实际url的生成逻辑

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
Angular里routerLink指令实际url的生成逻辑

相关文章:

  • 2021-11-23
  • 2022-01-09
  • 2022-03-07
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
猜你喜欢
  • 2021-04-17
  • 2021-12-23
  • 2021-09-11
  • 2021-09-27
  • 2021-05-22
  • 2021-05-19
相关资源
相似解决方案