当前位置:网站首页>SAP Spartacus 默认路由配置的工作原理
SAP Spartacus 默认路由配置的工作原理
2022-06-26 21:18:00 【华为云】
这个默认配置文件的名称:default-routing-config.ts

查看哪些地方消费了 defaultRoutingConfig:

provudeDefaultConfig 是一个 helper 函数:

这个 RoutingModule.forRoot 方法又会在什么时候被调用呢?

在这两处:base-storefront.module.ts 和 storefront-foundation.module.ts:

注意 forRoot 方法返回参数的类型:ModuleWithProviders:
因为 import 这些 module 的消费 module,imports 区域的类型就是 any[] | Type<any> | ModuleWithProviders<{}>)[]


关于 ValueProvider 各参数的说明:

provide:注入令牌。通常是 Type 或 InjectionToken 的实例,但也可以是 any 实例。
multi:如果为 true,则注入器返回实例数组。这对于允许多个提供者散布在多个文件中以向公共令牌提供配置信息很有用。
一个例子:
const locale = new InjectionToken<string[]>('locale');const injector = Injector.create({ providers: [ {provide: locale, multi: true, useValue: 'en'}, {provide: locale, multi: true, useValue: 'sk'}, ]});const locales: string[] = injector.get(locale);expect(locales).toEqual(['en', 'sk']);ModuleWithProviders:对 NgModule 及其相关 providers 的包装。
边栏推荐
- 剑指 Offer II 098. 路径的数目 / 剑指 Offer II 099. 最小路径之和
- Sword finger offer II 098 Number of paths / Sword finger offer II 099 Sum of minimum paths
- VB.net类库——4给屏幕截图,裁剪
- C language simple login
- [serial] shuotou O & M monitoring system 01 overview of monitoring system
- Two methods of QT to realize timer
- Leetcode: hash table 08 (sum of four numbers)
- Is there any risk in opening a mobile stock registration account? Is it safe?
- Shiniman household sprint A shares: annual revenue of nearly 1.2 billion red star Macalline and incredibly home are shareholders
- Simple Lianliankan games based on QT
猜你喜欢

windows系統下怎麼安裝mysql8.0數據庫?(圖文教程)

Leetcode(452)——用最少数量的箭引爆气球

Muke 8. Service fault tolerance Sentinel

windows系统下怎么安装mysql8.0数据库?(图文教程)

12个MySQL慢查询的原因分析
MongoDB实现创建删除数据库、创建删除表(集合)、数据增删改查

QT环境下配置Assimp库(MinGW编译器)

Matrix calculator design for beginners of linear algebra based on Qt development

龙芯中科科创板上市:市值357亿 成国产CPU第一股

传纸条【动态规划】
随机推荐
基于启发式搜索的一字棋
Stringutils judge whether the string is empty
手机股票注册开户有没有什么风险?安全吗?
windows系統下怎麼安裝mysql8.0數據庫?(圖文教程)
Leetcode question brushing: String 06 (implement strstr())
Looking back at the moon
c语言99乘法表
DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力
swagger:如何生成漂亮的静态文档说明页
Fixed length memory pool
SentinelResource注解詳解
基于SSH框架的学生信息管理系统
聊聊我的远程工作体验 | 社区征文
宝藏又小众的覆盖物PBR多通道贴图素材网站分享
Leetcode question brushing: String 02 (reverse string II)
股票炒股注册开户有没有什么风险?安全吗?
0 basic C language (3)
Redis + Guava 本地缓存 API 组合,性能炸裂!
Leetcode question brushing: String 01 (inverted string)
Détails de l'annotation des ressources sentinelles