我们试图在一个现有的项目上实现斯巴达克斯,现在面临的问题是为每个现有的基地提供不同的样式(例如“电子产品”,“外观”)。因此,通过URL,我们可以访问每个基本站点的内容(electronics.local:4200和appearal.local:4200由相同的应用程序提供,但内容不同)。如何通过为Spartacus中的每个basesite设置CMS (后台)中的主题属性来配置不同的样式(如加速器中的样式)?
提前感谢!
发布于 2020-11-17 13:39:25
在斯巴达克斯松通道的某种帮助下,我找到了一种解决方案,它是安静的、坚实的,但没有直接链接到CMS (后台)的基本站点的主题属性。它只是检索当前的BaseSite,并据此向app.component中的cx标记添加了一个类。
app.component.ts:
export class AppComponent {
public $activeSite: Observable<string> = this.baseSiteService.getActive();
constructor(
private baseSiteService: BaseSiteService
) {
}
}app.component.html:
<ng-container *ngIf="$activeSite | async as activeSite">
<cx-storefront [ngClass]="activeSite"></cx-storefront>
</ng-container>现在,我在class面dom元素中有了一个css-类,它等于当前的BaseSite UID,并且能够相应地应用我的样式:
<cx-storefront class="electronics stop-navigating" _ngcontent-ipq-c296="" ng-reflect-ng-class="electronics" tabindex="0">https://stackoverflow.com/questions/64860725
复制相似问题