当前位置:网站首页>SAP Spartacus 如何根据 page layout 获得对应支持的 slots
SAP Spartacus 如何根据 page layout 获得对应支持的 slots
2022-07-20 10:07:00 【华为云】
在 SAP Spartacus PageLayout Component 的实现里,每一个 layoutName 对应都有一个 cxOutlet 可供扩展:
第 13 行的 ngFor 指令,将该实现类的 slots$ 展开,为每一个 slot 放置对应的 CMS Component.
slots$ 是一个数组,通过 pageLayoutService.getSlots 方法获取。
本文介绍这个 getSlots 方法的执行明细。
switchMap 这个 rxjs 操作符,暗示了其传入的箭头函数,是一个 cancellable 的耗时操作。
在这个闭包内执行:
combineLatest:只要 this.page$ 和 this.breakpointService.breakpoint$ 有一个被订阅,就会触发 map 操作:
支持的所有 slots 和 slots 里面允许的 Components 列表:
breakpoint:xl
读取 slot 配置:
所有 template 配置都在 tis.config.layoutSlots 里了:
拿到了 header 的配置:
最终结果:
关于 SAP Spartacus defaultCmsContentProvider 和默认 layoutConfig 的一些测试
以 Spartacus-b2c-configuration.module.ts 文件为例:
这些默认的配置文件,都是从另一个库,即 @Spartacus/Storefront 里导入的,后者的入口是 public_api 文件:
在这个文件里加上一行打印语句,可以看到所有默认的配置:
这些默认配置硬编码在 layout-config.ts 内:
如果注释掉一部分:
效果如下:Header 区域整个没了。
再把 footer 区域也注释掉:
现在 header 和 footer 都没了:
边栏推荐
猜你喜欢
随机推荐
Win10账户初始化配置
C# DataGridView数据导出Excel文件
Custom persistence layer framework myormframework (III) - framework implementation
CentOS install MySQL
低代码开发平台搭建会展服务管理系统案例分析
vs2019配置Qt5开发环境
strcat() - 连接字符串
怎样判断你长得像哪位明星人物?
煤炭行业供应链集采系统:数字化推进煤炭产业转型升级
Strcat () - connection string
6G: typical applications, key technologies and challenges
Ankerui motor monitoring scheme low voltage motor circuit and feeder distribution circuit power energy monitoring
LeetCode简单题之重排字符形成目标字符串
ORACLE 11G 数据库异机恢复到另外的目录
9 redis stress test redis benchmark
一起来自定义loader吧
[u-boot] main line analysis of u-boot operation [02] - board_ init_ f
【u-boot】u-boot运行主线分析【01】—_main
Redis sortset type
10 GHz室内无线体域网无线信道测量与建模