通过单步调试理解Angular里routerLink指令实际url的生成逻辑
My Analysis
I set a breakpoint in function generateUrlPart in file Spartacus-core.js:
For every path stored in routeConfig.paths, this function evaluates if route parameter passed by developers in can match ALL.
Since I only specify “code” in my custom component template html,
the evaulation will fail of course, as no counterpart exists for another parameter “name”:
solution
After I add the other necessary route parameter nameForUrl: ‘Jerry’ in my html:
this time function generateUrlPart can return the expected result:
This time route works since the static url is generated successfully and contained in the rendered html.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
總結
以上是生活随笔為你收集整理的通过单步调试理解Angular里routerLink指令实际url的生成逻辑的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 今年是SAP进入中国25周年,我从200
- 下一篇: 表现超预期!亚马逊一季度扭亏为盈 净利3