- 如何访问SAP Spartacus里的config数据
- SAP Spartacus 默认的 pwa,处于关闭状态还是打开
- 关于 SAP 电商云首页加载时触发的 OCC API 请求
- SAP 电商云 Spartacus UI 里如何捕捉语言设置的更
- SAP 电商云 Spartacus UI 产品搜索结果的设计明细
- 自定义SAP Spartacus的产品搜索API参数
- SAP 电商云 Spartacus 服务器端渲染的单步调试详细步
- SAP Spartacus的navigation初始化
- 让 fork 出来的 Github 仓库从远端仓库拖取最新的修改
- SAP Spartacus里使用Observable访问Comp
App module里调用ConfigModule.withConfig注入配置,调用两次withConfig,传入的参数会进行合并:

ConfigModule.withConfig({
cmsComponents: {
SimpleResponsiveBannerComponent: {
component: MycomComponent
},
CartComponent: {
component: MyCartComponent
}
} as CmsConfig
}),
ConfigModule.withConfig({
someCustomComponent: {
a: "b"
}
})
通过构造函数参数注入:

export class AppComponent implements OnInit {
constructor(private componentFactoryResolver: ComponentFactoryResolver,
private outletService: OutletService<ComponentFactory<MycomComponent>>
, @Inject(Config) private config: any) { }
运行时的配置信息:
cmsComponents就是我在app Component里调用withConfig进行的配置:

其中绝大部分属性都是Spartacus的默认配置,只有下图这个是我在代码里更改过的:

这是我传入的另一个自定义配置:

注入时也可以显式地指定配置的类型,比如:
export class AppComponent implements OnInit {
constructor(private componentFactoryResolver: ComponentFactoryResolver,
private outletService: OutletService<ComponentFactory<MycomComponent>>
, @Inject(Config) private config: any,
@Inject(Config) private cmsConfig: CmsConfig) {
debugger;
}



网友评论