问题标签 [spartacus-storefront]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
spartacus-storefront - 替换现有 ProductListComponent 时激活路由的问题
我试图ProductListComponent
用自定义替换。问题是当我转到 url 时,例如http://localhost:4200/c/584
,激活的路由没有任何参数。但我期待categoryCode
或brandCode
。什么问题?
组件代码:
配置:
angular - 在 Storybook 中显示 Spartacus 组件的问题
我们遇到了 Spartacus、Angular 和 Storybook 组合的问题。
对于那些不熟悉的人:Storybook 是一个 UI 开发环境,它能够以独立的方式展示 UI 组件,并带有一些游乐场功能(更多信息在这里:https ://storybook.js.org/docs/basics/introduction/ )。我们希望能够在 Storybook 中展示从 Spartacus 库导入的一些 UI 组件,以便能够与我们的视觉设计器就我们将使用的 UI 元素创建一致的叙述。
Storybook 具有 Angular 支持,对于简单的组件,配置 Storybook 以查看定义的组件(定制的或来自库的)就足够了,它将在 Storybook 环境中显示它。对于更复杂的 Angular 组件,还可以通过模块元数据提供“模拟”上下文,该元数据可以包含导入和声明等内容,就像常规 Angular 模块一样(更多信息:https ://www.learnstorybook.com/intro -to-storybook/angular/en/composite-component/)。
在 Storybook 中简单地指向 Spartacus 中的组件时,如果没有任何其他数据,则会出现很多关于缺少声明的错误。此屏幕截图中的示例:
显示缺少“cxTranslate”和“cx-icon”声明的故事书错误
通过模块元数据导入包含缺失声明的模块,许多这些问题似乎都得到了解决。然而,我们真正的问题在于管道(如屏幕截图中提到的“cxTranslate”管道)。因为 Spartacus 在几乎所有组件模板中都使用像 cx-translate/TranslatePipe 这样的管道,所以必须导入它们才能使组件正常工作。但是,如下文所示,将这些管道添加到 Storybook 的模块元数据声明中并不能(完全)解决问题。
searchbox.stories.ts:
该组件的 Storybook 页面将不再抱怨管道名称不存在,但它会在 Storybook 环境中显示空白组件并导致 DevTools 控制台中出现错误(见下文)。
DevTools 控制台显示 ERROR NullInjectorError: StaticInjectorError(DynamicModule)[store]
我可以找到有关在线信息的许多导致此错误的一般 Angular 问题似乎是导入/声明丢失或使用不当的问题。但是,我还没有找到使 Spartacus 组件在 Storybook 中工作的配置。
任何人都可以帮助阐明这个问题吗?
oauth - Spartacus 扩展 AuthService
是否可以扩展 Auth Service 并为其添加其他参数?
目前正在尝试扩展但遇到如下错误:
src/app/service/auth/auth-extend.service.ts(15,3) 中的错误:错误 TS2416:“AuthExtendService”类型中的属性“授权”不可分配给基本类型“AuthService”中的相同属性。
类型 '(userId: string, password: string, countryCode: string, businessType: string) => void' 不可分配给类型 '(userId: string, password: string) => void'。
src/app/service/auth/auth-extend.service.ts(21,7): error TS2345: Argument of type '{ userId: string; 密码:字符串;国家代码:字符串;业务类型:字符串;}' 不能分配给 '{ userId: string; 类型的参数;密码:字符串;国家代码:字符串;业务类型:字符串;}'。
对象字面量只能指定已知属性,但类型 '{ userId: string; 中不存在 'businessType' 密码:字符串;国家代码:字符串;业务类型:字符串;}'。你的意思是写“businessType”吗?"
这里的任何人都试图这样做,比如添加新参数。
spartacus-storefront - Spartacus - 尝试代理请求时发生错误
在 localhost 的 spartacus 应用程序中执行 yarn start 时,出现以下错误:
我有相当标准的 proxy.bankend.js 文件。有什么建议我可以调查吗?我已经测试过后端可以直接通过 url 访问。
问候,建筑师
spartacus-storefront - Why does my local checkout fails on Spartacus 1.5?
The Error
I am not able to perform checkout on both of my local powertools and electronics sites. The Chrome console log complains about the error shown above. Also, I have tried opening the given link in a new tab and it says No content page found matching the provided label or id: /checkout
. Checked the WCMS Pages in my local Backoffice, I couldn't find any page with label or id as "checkout".
Could it be that I have to setup my local with the b2c_for_spartacus
? (I have setup mine with b2c_b2b_acc_oms
recipe instead)
spartacus-storefront - 扩展 OOTB Spartacus Product 和 Occ.Product UI 模型
我创建了Product
. 这很好,但我有一个关于使用自定义扩展类型的Product
服务的问题。
例如,我的自定义 OCC 产品模型和CustomProduct
UI 模型有额外的字段(例如字符串字段)。我扩展了Occ.Product
和Product
接口。但是,例如在ProductSummaryComponent
财产product$
中没有我的领域。我的建议是它有product$: Observable<Product> = this.currentProductService.getProduct();
- Product
UI 模型。
问题:
我想在CustomProduct
任何地方使用我的自定义 UI 模型而不是 Spartacus 的 OOTB 产品 UI 模型,对于 OOTB SpartacusOcc.Product
模型也是如此。文档仅描述了如何创建自定义 UI 模型并在Normalizer
. 但是,如果我需要在任何地方(服务、适配器、转换器等)通过自定义替换 OOTBProduct
或UI 模型怎么办?Occ.Product
spartacus-storefront - 如何隐藏面包屑但保存 H1 页面标题
我试图控制面包屑的可见性取决于BreadcrumbComponent
CMS 页面结构中的可用性。
但是基于breadcrumb.component.html
,如果我们删除这个组件 - H1 标题也将被删除:
我们可以通过 Page Meta Resolver 处理面包屑可见性,这是解决这种情况的最有效的方法,还是 Spartacus 会将 H1 标题和面包屑分成单独的组件?
hybris - SAP Hybris B2b 1905 示例 yb2bacceleratorstorefront url 未打开
B2bStorefrontModule 不包含在最新版本中。您能否建议我如何使用 hybris 1905 版本在 app.module.ts 中添加此模块。
angular - 状态中不存在功能名称“siteContext”,因此 createFeatureSelector 无法访问它
可以修复/避免以下警告吗?
我看到createFeatureSelector(featureName)存储函数被多次调用。第一次调用“siteContext”作为 featureName 时,状态不会被初始化,因此警告消息会显示到控制台(仅在开发模式下)。
我正在使用spartacus/core和spartacus/storefront的 1.2.1 版
spartacus-storefront - OutletService 是否支持在按钮处理程序中动态添加组件
我用 this.outletService.add('BottomHeaderSlot', factory, OutletPosition.BEFORE); 在搜索按钮单击处理程序期间,在 BottomHeaderSlot 中添加自定义组件。我打算在标题下添加 searchOverlay 以添加自定义搜索行为。
但是我的自定义组件在调用 outletService.add 后没有显示在标题下。我参考了这个https://sap.github.io/cloud-commerce-spartacus-storefront-docs/outlets/。outletService 是否支持在运行时动态添加组件?
以下是我的按钮处理程序