如何覆盖特定的斯巴达克斯组件

发布于 2025-01-25 13:10:24 字数 128 浏览 2 评论 0原文

我在斯巴达克斯两次使用相同的组件,但使用不同的数据。

我正在尝试覆盖此组件,但是如果我用类型代码覆盖它,它们都将相同,而我仍然需要它们不同。

有没有一种方法可以使用特定的ID来定位组件的特定实例而不是覆盖所有组件?

I am using the same component twice in Spartacus but with different data.

I am trying to override this component but if I override it with the type code they will both be identical while I need them to still be different.

Is there a way to use a specific id to target a specific instance of the component instead of overriding all of them ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山色无中 2025-02-01 13:10:24

在您的情况下,由于两个组件是相同的,但具有不同的数据,因此我认为数据将作为输入。

在这种情况下,我建议在app.component.html文件中使用插座。例如:

<ng-template cxOutletRef="section1" >
  <component [inputData]="data1"></component>
</ng-template>

<ng-template cxOutletRef="section2" >
  <component [inputData]="data2"></component>
</ng-template>

In this case, they would be rendered in their respective sections but with different data. Does this answer your question?

In your case, since the two components are the same but have different data, I assume the data would come as input.

In this case, I would suggest using outlets in the app.component.html file. For example:

<ng-template cxOutletRef="section1" >
  <component [inputData]="data1"></component>
</ng-template>

<ng-template cxOutletRef="section2" >
  <component [inputData]="data2"></component>
</ng-template>

In this case, they would be rendered in their respective sections but with different data. Does this answer your question?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文