SAPUI5 Walkthrough Step 26: Remote OData Service
2021/8/7 23:08:18
本文主要是介绍SAPUI5 Walkthrough Step 26: Remote OData Service,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
Step 26: Remote OData Service
在之前的开发中,我们都是用了本地的JSON数据来进行开发。这一步我们将调用OData接口,来提供我们所需的OData数据。
可以免费使用的Odata服务 https://www.odata.org/odata-services/
修改 webapp/manifest.json文件, 增加Datasource, 修改Models:invoice
{ "_version": "1.7.0", "sap.app": { "id": "sap.ui.demo.walkthrough", "type": "application", "i18n": "i18n/i18n.properties", "applicationVersion": { "version": "1.0.0" }, "title": "{{appTitle}}", "description": "{{appDescription}}", "sourceTemplate": { "id": "ui5template.basicSAPUI5ApplicationProject", "version": "1.40.12" }, "dataSources": { "invoiceRemote": { "uri": "https://services.odata.org/V2/Northwind/Northwind.svc/", "type": "OData", "settings": { "odataVersion": "2.0" } } } }, ...... "sap.ui5": { ...... "models": { "i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "sap.ui.demo.walkthrough.i18n.i18n" } }, "invoice": { "dataSource": "invoiceRemote" } }, "resources": { "css": [{ "uri": "css/style.css" }] } } }
执行
执行无数据, F12查看 Console,错误信息如下:
Access to XMLHttpRequest at 'https://services.odata.org/V2/Northwind/Northwind.svc/$metadata?sap-language=ZH' from origin 'http://localhost:53084' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看sap的建议,解决无果
https://sapui5.hana.ondemand.com/#/topic/5bb388fc289d44dca886c8fa25da466e.html
参考下述文章后(复制一个Chrome浏览器,然后在浏览器右键属性目标框中拼接 --user-data-dir="c:\ChromeDebug" --test-type --disable-web-security)后能CORS问题解决
https://blog.csdn.net/u014089637/article/details/118904009
执行
这篇关于SAPUI5 Walkthrough Step 26: Remote OData Service的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-04el-table 开启定时器下,表格的选中状态会消失是什么原因-icode9专业技术文章分享
- 2024-10-03如何安装和初始化飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03如何安装 App 并连接到飞牛 NAS?-icode9专业技术文章分享
- 2024-10-03如何安装飞牛 TV 并连接到影视服务器?-icode9专业技术文章分享
- 2024-10-03如何在PVE和ESXI上安装飞牛私有云 fnOS?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS安装系统异常情况处理-icode9专业技术文章分享
- 2024-10-03飞牛NAS如何创建存储空间?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS硬盘会自动休眠吗?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何安装飞牛影视和创建媒体库?-icode9专业技术文章分享
- 2024-10-03fnOS国产最强NAS如何为家人朋友开通影视账号?-icode9专业技术文章分享