SAPUI5 错误资源 URL

SAPUI5 Error resource URL

我正在为移动应用程序在 SAPUI5 中编程,并且我正在使用 SAPUI 工具开发人员。

我使用 XML 应用程序视图创建了一个默认项目。

我收到以下错误:

2015-02-12 15:44:21 Device API logging initialized - DEVICE
sap-ui-core.js:80 2015-02-12 15:44:21 registerResourcePath ('', 'https://openui5.hana.ondemand.com/resources/') -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21 registerResourcePath ('com/maxinst', './') -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21 registerResourcePath ('com/maxinst/mobile', 'maxinstmobile/') -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21 URL prefixes set to: -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21   (default) : https://openui5.hana.ondemand.com/resources/ -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21   'com/maxinst' : ./ -  sap.ui.ModuleSystem
sap-ui-core.js:80 2015-02-12 15:44:21   'com/maxinst/mobile' : maxinstmobile/ -  sap.ui.ModuleSystem
sap-ui-core.js:27 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/thirdparty/jquery-mobile-custom.js".
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/core/library-preload.json".
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/m/library-preload.json".
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/commons/library-preload.json".
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/layout/library-preload.json".
sap-ui-core.js:27 XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/core/themes/sap_bluecrystal/library-parameters.json".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/m/themes/sap_bluecrystal/library-parameters.json".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/layout/themes/sap_bluecrystal/library-parameters.json".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/commons/themes/sap_bluecrystal/library-parameters.json".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/m/messagebundle_en_US.properties".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "http://localhost:8080/maxinstMobile/Component-preload.js".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "http://localhost:8080/maxinstMobile/Component.js".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/thirdparty/signals.js".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/thirdparty/hasher.js".
https://openui5.hana.ondemand.com/resources/sap-ui-core.js XHR finished loading: GET "https://openui5.hana.ondemand.com/resources/sap/ui/thirdparty/crossroads.js".
UIComponent.js:6 Uncaught Error: resource URL './' has unknown type (should be one of .properties,.hdbtextbundle)

我该如何解决这个问题?

错误消息具有误导性。它是由 sap-ui-core.js 中的 Bundle JavaScript 函数抛出的。该函数用于打开资源包文件,例如 messageBundle_en_US.properties。也就是说,当您在 index.html 初始化中注册路径时不会抛出错误,但稍后在您的代码中尝试打开资源包文件时会抛出错误。以下是示例项目中 Components.jsinit() 函数的示例:

const i18nModel = new sap.ui.model.resource.ResourceModel(
    {bundleUrl : [rootPath, mConfig.resourceBundle].join("/")}
);

如果 mConfig 变量或 resourceBundle 属性 未定义,那么您将看到错误消息。在这种情况下,您可以将 mConfig.resourceBundle 替换为文字字符串,例如 i18n/messageBundle.properties 以测试这是否是您的问题。

在我的例子中,mConfig 没有定义。那是一个不同的问题,我现在要去解决它。