共计 650 个字符,预计需要花费 2 分钟才能阅读完成。
需要
https://stackoverflow.com/que…
实现原理
AFAIK, currently we do not have anything similar to CurrentProductService for current category.
以后 SAP Spartacus 规范实现里,不足相似 CurrentProductService 对产品明细页面那样的反对。
Looking at the implementation of CurrentProductService you can see that it is using RoutingService and it’s getRouterState() method (picture 1).
钻研 CurrentProductService 的实现代码,发现其实现原理是,首先利用 RoutingService,从 RouterState 中拿到以后页面的产品 code,而后应用另一个 API,productService, 来读取产品的明细数据。
You can create something similar for current category, because the router state consists of category informations (as seen below on picture 2).
因而咱们能够采取相似的思路,从 category 页面的 State 里,提取出 category 明细信息:
- categoryCode
- param0, param1, param2
更多 Jerry 的原创文章,尽在:” 汪子熙 ”:
正文完