当前位置:网站首页>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 的包装。
边栏推荐
- VB.net类库(进阶版——1)
- StringUtils判断字符串是否为空
- Two methods of QT to realize timer
- Yonghui released the data of Lantern Festival: the sales of Tangyuan increased significantly, and several people's livelihood products increased by more than 150%
- Vi/vim editor
- 财务费用分析怎么分析
- 这些地区考研太疯狂!哪个地区报考人数最多?
- The importance of using fonts correctly in DataWindow
- C: Reverse linked list
- Chapter 2 construction of self defined corpus
猜你喜欢

茂莱光学科创板上市:拟募资4亿 范一与范浩兄弟为实控人

Sword finger offer 12 Path in matrix

Cause analysis of 12 MySQL slow queries

Looking back at the moon

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

Redis + Guava 本地缓存 API 组合,性能炸裂!
![[serial] shuotou O & M monitoring system 01 overview of monitoring system](/img/b2/bc75a4d0c8d98056d93ba99b3e6193.png)
[serial] shuotou O & M monitoring system 01 overview of monitoring system
MongoDB实现创建删除数据库、创建删除表(集合)、数据增删改查

基于QT开发的线性代数初学者的矩阵计算器设计

VB.net类库,获取屏幕内鼠标下的颜色(进阶——3)
随机推荐
DAST 黑盒漏洞扫描器 第五篇:漏洞扫描引擎与服务能力
Garbage collection mechanism of browser
0 basic C language (0)
Shiniman household sprint A shares: annual revenue of nearly 1.2 billion red star Macalline and incredibly home are shareholders
记录一次Redis大Key的排查
C language 99 multiplication table
网上开户万一免五到底安不安全?
JWT operation tool class sharing
[protobuf] some pits brought by protobuf upgrade
Stop being a giant baby
Leetcode(763)——划分字母区间
网易云信正式加入中国医学装备协会智慧医院分会,为全国智慧医院建设加速...
GameFi 活跃用户、交易量、融资额、新项目持续性下滑,Axie、StepN 能摆脱死亡螺旋吗?链游路在何方?
What are the accounting elements
y48.第三章 Kubernetes从入门到精通 -- Pod的状态和探针(二一)
leetcode刷题:哈希表08 (四数之和)
俞敏洪:新东方并不存在倒下再翻身,摧毁又雄起的逆转
Gamefi active users, transaction volume, financing amount and new projects continue to decline. Can axie and stepn get rid of the death spiral? Where is the chain tour?
慕课11、微服务的用户认证与授权
基于QT开发的线性代数初学者的矩阵计算器设计