SAP Spartacus在某些屏幕尺寸下无法正常工作的原因分析
有個使用SAP Spartacus的客戶遇到一個問題:
We are getting one issue in our Spartacus application (currently we are on 2.1 version).
When we are trying to load checkout-login page with 100% zoom in the browser, it is loading not-found page instead of checkout-login page and when the same page is refreshed with 90% zoom in the browser, we can see the correct checkout-login page with proper data.
這個問題乍一看有點奇怪,當瀏覽器縮放比率為90%時,checkout-login 頁面可以正常工作,但是當縮放率調至100%時,反而不能正常工作了,會顯示not-found頁面。
We checked the cms-page.guard.ts file in that it is going to canActivateNotFoundPage method instead of canActivatePage from canActivate Method.
原因分析
we found an error in “CustomOccCmsPageNormalizer” at:
問題是下面這段客戶自開發代碼引起的:
accountNavigationChildren = accountNavigationChildren.concat(supportComponentData.navigationNode );It seems like “supportComponentData” is undefined in some case. This variable contains the “MySupportComponent” component from the response. Since “supportComponentData” is undefined an error is thrown which causes the “checkout-login” page rendering to fail. Spartacus then falls back to getting the “not found” page.
To explain further, in the “CmsPageGuard”, Spartacus calls “CmsService.getPage” which will try to load the checkout page.
Since there is an error in the page normalizer, the “CmsService” will return “false” to the “CmsPageGuard” meaning the page wasn’t rendered. The “CmsPageGuard” then goes ahead and requests the “not found” page.
Because of an “if statement” wrapping the failing logic, the problem is only visible for screen sizes between 768 and 1399 (inclusively).
這個問題只有在屏幕尺寸位于區間768~1399區域內才能重現。
Additionally, we were not able to witness this same problem on the d1 server which might mean that the p1 server is missing the “MySupportComponent”.
總結
以上是生活随笔為你收集整理的SAP Spartacus在某些屏幕尺寸下无法正常工作的原因分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VBA控制菜单栏上的菜单(如页面设置、打
- 下一篇: win10 经常自动断网,修复时提示:&