0

为了使 smartedit 工作,spartacus文档指出,有必要在 index.html 中提供 webApplicationInjector.js 脚本。

此外,需要使用 smartedit 实例列表设置值“data-smartedit-allow-origin”。

像这样:

<script id="smartedit-injector" src="webApplicationInjector.js" data-smartedit-allow-origin="localhost:9002"></script>

但是 Prod-Environments 的最佳实践是什么?是否有使用特定环境覆盖此值的构建过程?

因为我不想在 index.html 中列出所有可能的环境,包括 localhost。

任何帮助,将不胜感激。

非常感谢,朱利安

4

2 回答 2

0

您可以在 Angular 环境模型中设置多个环境属性,请参阅https://angular.io/guide/build或更多信息。然后您需要动态添加 smartedit 注入器,同时考虑环境属性。您也可以使用这种方法延迟加载脚本,因为普通访问者不需要它。您可以在https://github.com/SAP/cloud-commerce-spartacus-storefront/issues/3805#issuecomment-543090561阅读我们的意图。

于 2020-02-04T19:03:53.983 回答
0

我更希望有一种类似于“occ-backend-base-url”的方法。

延迟加载工作正常。但是,'launchInSmartEdit' 值尚未在 app.component 中设置,因此我们必须手动检查 url 中的 'cx-preview' 值。

但这就是诀窍。

谢谢

于 2020-02-07T11:09:00.177 回答