共计 5230 个字符,预计需要花费 14 分钟才能阅读完成。
以笔者本套教材为例,每一步骤的源代码都托管在自己 Github 仓库里,每次上传之前,都确保本地测试通过。
但笔者编写过程中发现,之前测试通过的代码,可能几个月之后再执行,就会遇到白屏景象,即利用无奈失常加载,或者无奈在调试模式下失常加载。
举个具体的例子。本文写作于 2022 年 11 月 20 日,进入步骤 6,运行命令行 ui5 serve
:
应用这个 url
,能够失常关上 SAP UI5 利用:
应用快捷键 Ctrl+Shift+Alt+P
切换到调试模式,而后依据如下 url,竟然无奈关上利用了:
http://localhost:8080/webapp/index.html?sap-ui-debug=true
谬误音讯:
ui5loader-dbg.js:1283 Access to XMLHttpRequest at ‘https://sapui5.hana.ondemand….’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
loadSyncXHR @ ui5loader-dbg.js:1283
requireModule @ ui5loader-dbg.js:1538
requireAll @ ui5loader-dbg.js:1730
executeModuleDefinition @ ui5loader-dbg.js:1796
ui5Define @ ui5loader-dbg.js:1929
eval @ Core-dbg.js?eval:8
execModule @ ui5loader-dbg.js:1645
requireModule @ ui5loader-dbg.js:1546
requireSync @ ui5loader-dbg.js:2056
(anonymous) @ sap-ui-core-dbg.js?bundle-code-0:1
ui5loader-dbg.js:1283 GET https://sapui5.hana.ondemand…. net::ERR_FAILED 404
loadSyncXHR @ ui5loader-dbg.js:1283
requireModule @ ui5loader-dbg.js:1538
requireAll @ ui5loader-dbg.js:1730
executeModuleDefinition @ ui5loader-dbg.js:1796
ui5Define @ ui5loader-dbg.js:1929
eval @ Core-dbg.js?eval:8
execModule @ ui5loader-dbg.js:1645
requireModule @ ui5loader-dbg.js:1546
requireSync @ ui5loader-dbg.js:2056
(anonymous) @ sap-ui-core-dbg.js?bundle-code-0:1
ui5loader-dbg.js:1283 Access to XMLHttpRequest at ‘https://sapui5.hana.ondemand….’ from origin ‘http://localhost:8080’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
loadSyncXHR @ ui5loader-dbg.js:1283
requireModule @ ui5loader-dbg.js:1538
requireAll @ ui5loader-dbg.js:1730
executeModuleDefinition @ ui5loader-dbg.js:1796
ui5Define @ ui5loader-dbg.js:1929
eval @ Core-dbg.js?eval:8
execModule @ ui5loader-dbg.js:1645
requireModule @ ui5loader-dbg.js:1546
requireSync @ ui5loader-dbg.js:2056
(anonymous) @ sap-ui-core-dbg.js?bundle-code-0:1
ui5loader-dbg.js:1283 GET https://sapui5.hana.ondemand…. net::ERR_FAILED 404
loadSyncXHR @ ui5loader-dbg.js:1283
requireModule @ ui5loader-dbg.js:1538
requireAll @ ui5loader-dbg.js:1730
executeModuleDefinition @ ui5loader-dbg.js:1796
ui5Define @ ui5loader-dbg.js:1929
eval @ Core-dbg.js?eval:8
execModule @ ui5loader-dbg.js:1645
requireModule @ ui5loader-dbg.js:1546
requireSync @ ui5loader-dbg.js:2056
(anonymous) @ sap-ui-core-dbg.js?bundle-code-0:1
ui5loader-dbg.js:1042 Uncaught ModuleError: Failed to resolve dependencies of ‘sap/ui/core/Core.js’
-> ‘sap/ui/core/ThemeCheck.js’: failed to load ‘sap/ui/core/ThemeCheck.js’ from https://sapui5.hana.ondemand…. Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘https://sapui5.hana.ondemand….’.
at makeModuleError (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1044:15)
at Module.failWith (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:816:13)
at https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1860:32
at requireAll (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1745:5)
at executeModuleDefinition (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1798:3)
at Object.ui5Define [as define] (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1931:3)
at eval (https://sapui5.hana.ondemand.com/resources/sap/ui/core/Core-dbg.js?eval:8:8)
at eval (<anonymous>)
at execModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1647:15)
at requireModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1548:5)
Caused by: ModuleError: failed to load ‘sap/ui/core/ThemeCheck.js’ from https://sapui5.hana.ondemand…. Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘https://sapui5.hana.ondemand….’.
at makeModuleError (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1044:15)
at Module.failWith (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:816:13)
at requireModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1545:13)
at requireAll (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1732:20)
at executeModuleDefinition (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1798:3)
at Object.ui5Define [as define] (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1931:3)
at eval (https://sapui5.hana.ondemand.com/resources/sap/ui/core/Core-dbg.js?eval:8:8)
at eval (<anonymous>)
at execModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1647:15)
at requireModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1548:5)
Caused by: Error: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘https://sapui5.hana.ondemand….’.
at loadSyncXHR (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1285:8)
at requireModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1540:5)
at requireAll (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1732:20)
at executeModuleDefinition (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1798:3)
at Object.ui5Define [as define] (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1931:3)
at eval (https://sapui5.hana.ondemand.com/resources/sap/ui/core/Core-dbg.js?eval:8:8)
at eval (<anonymous>)
at execModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1647:15)
at requireModule (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:1548:5)
at Object.requireSync (https://sapui5.hana.ondemand.com/resources/sap-ui-core-dbg.js:2058:23)
本文余下局部,介绍如何剖析这种怪问题。