我正在尝试使用命令 ng generate component test 创建一个组件。但我没有找到 module.ts 文件。我可以使用什么命令?谢谢。
问问题
198 次
2 回答
0
您可以尝试指定--module=app
参数。而不是app
您可以指定要在其中声明新组件的模块。
您还可以查看 Spartacus 提供的CMS 示意图。
于 2020-04-08T09:08:37.557 回答
0
我不是 100% 确定你为什么需要另一个模块 - 我已经在我的 Spartacus 实例中添加了一个自定义组件(使用 ng generate),但没有添加新模块,一切正常。
作为参考,我只是将新组件添加到我的 app.module.ts 中,如下所示:
import { GigyaRaasComponent } from './gigya-raas/gigya-raas.component';
@NgModule({
declarations: [
AppComponent,
GigyaRaasComponent
],
imports: [
BrowserModule,
B2cStorefrontModule.withConfig({
backend: {
occ: {
baseUrl: 'https://localhost:9002',
prefix: '/rest/v2/'
}
},
context: {
baseSite: ['electronics-spa']
},
i18n: {
resources: translations,
chunks: translationChunksConfig,
fallbackLang: 'en'
},
features: {
level: '*',
anonymousConsents: true
},
cmsComponents: {
GigyaRaasComponent: {
component: GigyaRaasComponent
}
}
})
],
providers: [],
bootstrap: [AppComponent],
entryComponents: [GigyaRaasComponent]
})
于 2020-04-08T09:12:26.690 回答