一个简单的workaround - 如何使用SAP Spartacus中的private API
技巧地址:
https://stackoverflow.com/questions/66871919/how-to-use-private-api-of-the-spartacus-library
原標題:How to use private API of the Spartacus library
注意:這只是一個折中方案。
Disclaimer: The private API of Spartacus should not be used in general. It may change at any time without any warning. You can use the following workaround on your OWN RISK. It might result in breaking your code after upgrading to any next version.
具體做法
Open file node_modules/@spartacus/xxxxx/spartacus-xxxxx.d.ts and find the exported alias name for the class, prefixed with symbol ?:
export { SomeClass as ?xyz } from '..........';Then you can use the alias in your application, for example to extend the class behavior:
import { ?xyz as SomeClass } from `@spartacus/core`;/* ... */// for example: @Injectable() export class CustomSomeClass extends SomeClass { /*...*/ }/* ... */ @NgModule({providers: [{ provide: SomeClass, useClass: CustomSomeClass }] })WARNING: the ?-alias might change in any next release of Spartacus without any warning. It’s not a part of the public API.
如下圖所示:
總結(jié)
以上是生活随笔為你收集整理的一个简单的workaround - 如何使用SAP Spartacus中的private API的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 王者新赛季会清空积分吗
- 下一篇: SAP Spartacus 自定义 Pa