@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, B2cStorefrontModule.withConfig({ backend: { occ: { baseUrl: 'https://spartacus-dev0.eastus.cloudapp.azure.com:9002', prefix: '/occ/v2/' } }, context: { currency: ['USD'], language: ['en'], baseSite: ['electronics-spa'] }, i18n: { resources: translations, chunks: translationChunksConfig, fallbackLang: 'en' }, features: { level: '2.1' } }) ], providers: [], bootstrap: [AppComponent] })
文件位置:“C:\Code\SPA\mystore\node_modules@spartacus\storefront_ivy_ngcc_\fesm2015\spartacus-storefront.js”
withConfig的逻辑:返回自身,同时使用调用方法传入的config实例化provider:
provideConfig的实现在Spartacus-core.js里.