天天看點

SAP Spartacus 伺服器端渲染程式設計規範

連結:

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對象:

SAP Spartacus 伺服器端渲染程式設計規範
SAP Spartacus 伺服器端渲染程式設計規範

繼續閱讀