Fiori学习专题二十五:Remote OData Service
之前我们都是使用本地JSON来显示发票清单。这节课我们将调用一个UI5公共的OData Service
1.由于本地开发访问OData服务https://services.odata.org/V2/Northwind/Northwind.svc/会产生跨域问题,所以这里我们需要使用代理
新建一个终端:执行:npm i -D ui5-middleware-simpleproxy 将此包作为新的开发依赖项安装在package.json中
2.在ui5.yaml文件中加入
specVersion: '3.0'
metadata:name: ui5.walkthrough
type: application
framework:name: OpenUI5version: "1.134.0"libraries:- name: sap.m- name: sap.ui.core- name: themelib_sap_horizon
server:customMiddleware:- name: ui5-middleware-simpleproxyafterMiddleware: compressionmountPath: /V2configuration:baseUri: "https://services.odata.org"
3.manifest.json调整
{"_version": "1.65.0","sap.app": {"id": "ui5.walkthrough","i18n": "i18n/i18n.properties","title": "{{appTitle}}","description": "{{appDescription}}","type": "application","applicationVersion": {"version": "1.0.0"}, "dataSources": {"invoiceRemote": {"uri": "V2/Northwind/Northwind.svc/","type": "OData","settings": {"odataVersion": "2.0"}}}},"sap.ui": {"technology": "UI5","deviceTypes": {"desktop": true,"tablet": true,"phone": true}},"sap.ui5": {"dependencies": {"minUI5Version": "1.108.0","libs": {"sap.ui.core": {},"sap.m": {}}},"models": {"i18n": {"type": "sap.ui.model.resource.ResourceModel","settings": {"bundleName": "ui5.walkthrough.i18n.i18n","supportedLocales": [""],"fallbackLocale": ""}},"invoice": {"dataSource": "invoiceRemote"}},"rootView": {"viewName": "ui5.walkthrough.view.App","type": "XML","id": "app"},"resources": {"css": [{"uri": "css/style.css"}]}}}