关于redux:如何在SAP-Spartacus-category-页面里拿到当前的category信息

需要

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的原创文章,尽在:”汪子熙”:

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理