【问题标题】:How to override/extend ProductGridItemComponent using an outlet in Spartacus?如何使用 Spartacus 中的插座覆盖/扩展 ProductGridItemComponent?
【发布时间】:2021-03-23 14:55:40
【问题描述】:

我遇到了一个案例,我应该在电子水疗基地站点中覆盖/扩展 ProductGridItemComponent。 通常,在 Spartacus 中覆盖组件时,可以添加这样的插座模板:

<ng-template cxOutletRef="ProductGridItemComponent">
  My custom code here
</ng-template>

但这似乎没有任何效果。如果我尝试覆盖 ProductListComponent 是有效的,但是我将不得不从源代码中复制大量代码以使其行为并看起来像 Spartacus 提供的代码。 是否可以仅覆盖 ProductGridItemComponent 或者我必须覆盖 ProductListComponent 并从头开始构建它?

-- 编辑--

我在另一个帖子上找到了答案。 How to customize lower level components in Spartacus?

ProductGridItemComponent 不可自定义。它必须在更高的层次上完成,ProductListComponent

【问题讨论】:

    标签: spartacus-storefront


    【解决方案1】:

    ProductGridItemComponent 似乎没有可供定制的渠道。另一种方法是扩展和覆盖组件以自定义其行为。

    【讨论】:

    • 你的意思是我应该扩展和覆盖ProductGridItemComponentProductListComponent?你能给我举个例子吗?
    • 我不知道您应该根据需要覆盖哪个,但如果不提供插座,您可以覆盖和扩展您需要自定义的组件。您可以查看此文档以获取有关如何执行此操作的信息sap.github.io/spartacus-docs/customizing-cms-components
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-11
    相关资源
    最近更新 更多