連結:
https://sap.github.io/spartacus-docs/server-side-rendering-coding-guidelines禁止使用隻有在浏覽器環境下才可用的全局對象,比如window, document, navigator等等,因為在伺服器端渲染模式下,這些對象不可用。
Do not access global objects that are available in the browser. For example, do not use the window, document, navigator, and other browser types, because they do not exist on the server.
看一個Github issue:
https://github.com/SAP/spartacus/issues/10201需要使用注入進來的document對象:
