javascript 打开 UI5 sap-ui-core.js 加载资源失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29016985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 09:57:59  来源:igfitidea点击:

Open UI5 sap-ui-core.js Failed to load resource

javascriptjquerycordovasapui5

提问by wanderingProgrammer

I've been trying to get started on building OpenUI5 apps using cordova. The latest issue I am facing is that I can't seem to use my local "resources" folder (where all the OpenUI5 js files are stored). I am running the index.html file on chrome with web security disabled to allow for cross platform calls (as I was getting an error for that when running it on chrome in normal mode).

我一直在尝试开始使用cordova 构建OpenUI5 应用程序。我面临的最新问题是我似乎无法使用我的本地“资源”文件夹(所有 OpenUI5 js 文件都存储在其中)。我在 chrome 上运行 index.html 文件并禁用网络安全以允许跨平台调用(因为我在正常模式下在 chrome 上运行它时遇到错误)。

I even tried running the index.html page using http-server, but that wouldn't display the page, instead only downloading it whenever I tried to access it on the browser.

我什至尝试使用 http-server 运行 index.html 页面,但这不会显示该页面,而是仅在我尝试在浏览器上访问它时才下载它。

Now when I try to load the page, chrome's developer tools gives me these errors.

现在,当我尝试加载页面时,chrome 的开发人员工具给了我这些错误

The html page has virtually no code. All I am trying to do is open up a blank page with the title "Hello World".

html 页面几乎没有代码。我要做的就是打开一个标题为“Hello World”的空白页面。

<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <!-- https://sapui5.hana.ondemand.com -->
    <!-- https://openui5.hana.ondemand.com -->
    <script  src= "./resources/sap-ui-core.js"
       id= "sap-ui-bootstrap"
       data-sap-ui-libs= "sap.m"
       data-sap-ui-theme= "sap_bluecrystal">
    </script>
    <title>Hello World</title>
</head>
<body class="sapUiBody">
    <div id="content" ></div>
</body>
</html>

Any solution as to how I can proceed would be highly appreciated.

任何关于我如何进行的解决方案都将受到高度赞赏。

PS: The library js files seem to work fine when accessed using the openui5.hana.ondemand.com/ or sapui5.hana.ondemand.com/ urls in place of "./resources/"

PS:使用 openui5.hana.ondemand.com/ 或 sapui5.hana.ondemand.com/ urls 代替“./resources/”访问时,库 js 文件似乎工作正常

PPS: The issue persists on the android emulator as well, so it's not a browser issue, I think.

PPS:这个问题在 android 模拟器上也仍然存在,所以我认为这不是浏览器问题。

回答by Emre

You can see there openui resources library. Take this resources file your www folder. And ? am using ../resources/sap-ui-core.jsmaybe help you.

你可以在那里 看到openui 资源库。将此资源文件放入您的 www 文件夹。和 ?我正在使用../resources/sap-ui-core.js可能会帮助你。

回答by Rafael Farias

Unfortunately core-ui is just one of the files that you need for OpenUI5.

不幸的是,core-ui 只是 OpenUI5 所需的文件之一。

If using Windows, and due to errors apparently you are, Chrome will not load other Javascript parts from a javascript file. So you needs a Web Server like Apache. Or you can try put this on your Chrome shortcut destination: "C:\Chrome\Application\chrome.exe" --allow-file-access-from-files file:///C:/OpenUI5/sdk/index.html

如果使用 Windows,并且由于您显然存在错误,Chrome 将不会从 javascript 文件加载其他 Javascript 部分。所以你需要一个像Apache这样的Web服务器。或者您可以尝试将其放在 Chrome 快捷方式目标上:“C:\Chrome\Application\chrome.exe” --allow-file-access-from-files file:///C:/OpenUI5/sdk/index.html

回答by Madhu

src= "https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
id= "sap-ui-bootstrap"
data-sap-ui-libs= "sap.m"
data-sap-ui-theme= "sap_bluecrystal"

or

或者

src= "resources/sap-ui-core.js"
id= "sap-ui-bootstrap"
data-sap-ui-libs= "sap.m"
data-sap-ui-theme= "sap_bluecrystal">