gpt4 book ai didi

sapui5 - 从错误路径加载library.js

转载 作者:行者123 更新时间:2023-12-01 22:55:42 24 4
gpt4 key购买 nike

我已将项目的 OpenUI5 从 1.42.7 更新到 1.60.12 (LTS)

如果我尝试使用新版本运行应用程序,则会出现此错误:

Uncaught Error: failed to load 'sap/ui/core/library.js' from resources/sap/ui/core/library.js: 404 - Not Found**

error

我的项目的树结构将 OpenUI5 文件放入 resources/openui路径:

current project folder structure

在index.html中,我设置了src在此模式下:

<script id="sap-ui-bootstrap"
src="resources/openui/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"
data-sap-ui-preload=""
data-sap-ui-resourceroots='{
"ui5bp": "./",
"model": "./model"
}'
></script>

看来是sap-ui-core.js的第一次调用正确完成(来自 Webcontent/resources<strong>/openui</strong> ),但随后调用 library.jsWebcontent/resources/ 调用,不是来自 Webcontent/resources/openui .

在1.42版本中,一切正常。
注意:如果我尝试从 CDN 检索 OpenUI5 资源,一切正常...

src="https://openui5.hana.ondemand.com/1.60.12/resources/sap-ui-core.js"

最佳答案

选项 1(推荐)

将 UI5 资源移动到正下方的 resources 文件夹中。

˅ 📂resources  ˃ 📁openui  ˅ 📂sap    ˃ 📁base    ˃ 📁f    ˃ 📁m    ...  ...  sap-ui-core.js

According to the topic Bootstrapping: Loading and Initializing - Initialization Process, UI5 will try to fetch library resources from the following path by default:

Library bootstrap file /<context-path><strong>/resources/<library-name></strong>/library(-preload).js

Having a deviating path (/resources/<strong>openui/</strong><library-name>/ in between) makes fetching the library files incompatible with default settings.

Option 2 (without changing the folder structure)

Define a new default base URL in index.html as early as possible. E.g. via the global configuration object:

<script>
window["sap-ui-config"] = {
resourceRoots: {
"": "./resources/openui/", // <-- new base URL
"ui5bp": "./",
// ...
},
libs: "sap.ui.core, sap.m",
async: true,
theme: "sap_belize",
compatVersion: "edge",
// ...
};
</script>
<script id="sap-ui-bootstrap" src="resources/openui/sap-ui-core.js"></script>

这个也有效,因为解决""将始终作为后备工作

Note that the empty prefix ("") will always match and thus serves as a fallback for any search. source

关于sapui5 - 从错误路径加载library.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55971473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com