首页 > 其他 > 详细

sapui5 walkthrough 26-30

时间:2019-10-01 10:39:39      阅读:102      评论:0      收藏:0      [点我收藏+]

Step 26: (Optional) Remote OData Service

使用远程的OData。

修改manifest.json

{
  "_version": "1.12.0",
  "sap.app": {
    ...
    "ach": "CA-UI5-DOC",
    "dataSources": {
      "invoiceRemote": {
        "uri": "https://services.odata.org/V2/Northwind/Northwind.svc/",
        "type": "OData",
        "settings": {
          "odataVersion": "2.0"
        }
      }
    }
  },
  "sap.ui": {
    ...
  },
  "sap.ui5": {
    ...
    "models": {
      "i18n": {
        "type": "sap.ui.model.resource.ResourceModel",
        "settings": {
          "bundleName": "sap.ui.demo.walkthrough.i18n.i18n"
        }
      },
      "invoice": {
        "dataSource": "invoiceRemote"
      }
    }
  }
}

在sap.app中添加数据源的配置,指定服务的type为odata,uri为该odata的地址,版本为2.0版本。

将model invoice的数据源,指定为invoiceRemote,会在组件初始化的时候,实例化模型。此配置允许组件在应用程序启动时,检索此模型的技术信息。

如果你希望在组件上有一个默认模型,那么可以在models中将模型命名为空字符串,

可以在component上使用this.getModel,来获取被自动实例化的model。

在基于component上的controller中,可以使用this.getView().getModel(),来获取被自动实例化的model。

如果要检索指定的model,那么需要将model的名字传递给getModel,比如这里用this.getModel("invoice") 。

运行之后会出现cross-origin的错误,可以在下面link中查看解决方法。

https://sapui5.hana.ondemand.com/#/topic/5bb388fc289d44dca886c8fa25da466e.html#loio5bb388fc289d44dca886c8fa25da466e__UsingHelperService

 

Step 27: Mock Server Configuration

 

sapui5 walkthrough 26-30

原文:https://www.cnblogs.com/suoluo119/p/11614878.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!