如何分析|如何分析 SAP Spartacus 路由问题之 CheckoutAuthGuard 单步调试
This document is written based on Spartacus 3.1.1.
The standard Storefront is used which is generated by Spartacus Schematics.
Suppose I would like to debug the executing of CheckoutAuthGuard for standard checkout step:Delivery Mode.
文章图片
It means I need to set some breakpoint in the step BEFORE Delivery Mode, in this case it is Shipping address step, and then click "Continue" button to trigger the breakpoint.
in your project, expand folder node_modules/@spartacus:
文章图片
then storefront/fesm2015, find file spartacus-storefront.js:
文章图片
Search by key word "CheckoutDeliveryMode", which is the default CMS component for Delivery Mode checkout step.
You see line 11037, the two standard component guard, CheckoutAuthGuard and CartNotEmptyGuard are defined there.
Add some product to carts, then open url:
http://localhost:4200/electronics-spa/en/USD/checkout/shipping-address
open Chrome Development tool,switch to Sources tab,press Ctrl+ O,type spa, then select spartacus-storefront.js from search list:
文章图片
then search by keyword CheckoutAuthGuard:
文章图片
【如何分析|如何分析 SAP Spartacus 路由问题之 CheckoutAuthGuard 单步调试】and set breakpoint in method canActivate.
Let's say if a checkout Component has configured Component guards A,B,C, only if all guards return true intheir canActivate method, then the corresponding checkout step page could be opened.
In my case I press "continue" button in Shipping Address page, then breakpoint is triggered.
文章图片
then you can debug to check the guard execution.
文章图片
As mentioned by document, canActivate method is expected to return true to achieve the routing of next checkout step.
更多Jerry的原创文章,尽在:"汪子熙":
文章图片
推荐阅读
- 考研英语阅读终极解决方案——阅读理解如何巧拿高分
- 如何寻找情感问答App的分析切入点
- D13|D13 张贇 Banner分析
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus使用queryWrapper如何实现复杂查询
- 如何在Mac中的文件选择框中打开系统隐藏文件夹
- 漫画初学者如何学习漫画背景的透视画法(这篇教程请收藏好了!)
- java中如何实现重建二叉树
- Linux下面如何查看tomcat已经使用多少线程
- thinkphp|thinkphp 3.2 如何调用第三方类库