SAP Spartacus使用cxComponentWrapper测试MiniCart
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus使用cxComponentWrapper测试MiniCart
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
該指令的作用是動態(tài)加載Component
如果將page-slot.component.html里的cxComponentWrapper指令注釋掉:
最后渲染的頁面將會一片空白:
如果僅僅打印position的值:
能看到SAP Spartacus所有可用的position:
如果將Component數(shù)據(jù)全部打印出來:
效果如下:
只渲染position為MiniCart的Component:
最后效果如下:
只有MiniCart被渲染了出來:
完整代碼:
<ng-template[cxOutlet]="position"[cxOutletContext]="{ components$: components$ }" ><ng-template*ngFor="let component of components"[cxOutlet]="component.flexType"[cxOutletContext]="{ component: component }"[cxOutletDefer]="getComponentDeferOptions(component.flexType)"(loaded)="isLoaded($event)"><div>position: {{ position }}</div><ng-container *ngIf="position === 'MiniCart'" [cxComponentWrapper]="component"></ng-container></ng-template> </ng-template>MiniCartComponent的Angular Component和CMS Component同名:
從OCC API返回的MiniCartComponent數(shù)據(jù):
從上圖能看出,Spartacus使用的CMS API,讀取的page數(shù)據(jù),類型字段名稱為typeCode, 而Spartacus CMS mapping使用的字段為flexType, 因此需要Spartacus的convertor / normalizer,在字段typeCode和flexType之間做轉(zhuǎn)換。
更多Jerry的原創(chuàng)文章,盡在:“汪子熙”:
總結(jié)
以上是生活随笔為你收集整理的SAP Spartacus使用cxComponentWrapper测试MiniCart的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 20款优秀的基于浏览器的在线代码编辑器「
- 下一篇: 啥是SBC_sbc是什么意思的缩写