当前位置: 移动技术网 > IT编程>网页制作>Html5 > HTML5开发移动web应用——SAP UI5篇(8)

HTML5开发移动web应用——SAP UI5篇(8)

2018年11月12日  | 移动技术网IT编程  | 我要评论
本次对之前学习的sap ui5框架知识进行简单小结,以及重点部分知识的梳理。 1、在ui5使用过程中,命名空间的概念很重要。 2、一般的sap引用格式如下: sap.ui

本次对之前学习的sap ui5框架知识进行简单小结,以及重点部分知识的梳理。

1、在ui5使用过程中,命名空间的概念很重要。

2、一般的sap引用格式如下:

sap.ui.define([
   "sap/ui/core/uicomponent",
   "sap/ui/model/json/jsonmodel",
   "sap/ui/model/resource/resourcemodel"], function (uicomponent, jsonmodel, resourcemodel) 

define后每引用sap的一个组件,后面的function就要传入一个对应的参数。

3、以下是component使用的基本框架:

sap.ui.define([
   "sap/ui/core/uicomponent"], function (uicomponent) {
   "use strict";
   return uicomponent.extend("", {
 
      init : function () {
         // call the init function of the parent
         uicomponent.prototype.init.apply(this, arguments);
}
   });});

component的构建流程如上,extenduicomponent这个框架,里面init为初始化函数,里面可以设定其他属性(包括配置模型等),如下:

sap.ui.define([
   "sap/ui/core/uicomponent",
   "sap/ui/model/json/jsonmodel",
   "sap/ui/model/resource/resourcemodel"], function (uicomponent, jsonmodel, resourcemodel) {
   "use strict";
   return uicomponent.extend("sap.ui.demo.wt.component", {
            metadata : {
rootview: "sap.ui.demo.wt.view.app"
},
      init : function () {
         // call the init function of the parent
         uicomponent.prototype.init.apply(this, arguments);
         // set data model
         var odata = {
            recipient : {
               name : "world"
            }
         };
         var omodel = new jsonmodel(odata);
         this.setmodel(omodel);
 
         // set i18n model
         var i18nmodel = new resourcemodel({
            bundlename : "sap.ui.demo.wt.i18n.i18n"
         });
         this.setmodel(i18nmodel, "i18n");
      }
   });});

4、注意manifest文件在一个应用中的重要性,manifest.json是app的配置文件。

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网