SAPUI5 - Component

UI5的Component概念:

UI5有两种Component:

一种是faceless component (class: sap.ui.core.Component), 这种component没有用户界面,一般用于从后台系统获取数据。

另一种是UI component(class: sap.ui.core.UIComponent), 这些组件是用于屏幕展示的,一般对应一个屏幕区域或者元素,可以被重复利用。

这两种component的基准类都是sap.ui.core.Component,可以通过继承基准类或者另一个component来扩展当前component的功能,构造Component的时候, 传入的名字为包名, 模块名(Module name)为包名+ .Component, 即通过jQuery.sap.declare或者在Component.js中extend方法中声明的名字.

例子:component.js文件如下

sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel",
"sap/ui/model/odata/v2/ODataModel",
"sap/ui/model/resource/ResourceModel"
], function (UIComponent, JSONModel,ODataModel,ResourceModel) {
"use strict";
return UIComponent.extend("sap.ui.demo.wt.Component", {
metadata : {
manifest: "json"
},
init : function () {
// call the init function of the parent
UIComponent.prototype.init.apply(this, arguments);
// set i18n model on view
var i18nModel = new ResourceModel({
bundleName: "sap.ui.demo.wt.i18n.i18n"
});
this.setModel(i18nModel, "i18n");
}
});
});

一个component就是一个文件夹, 文件夹名定义了component名并且包含了所有component可能用到的资源,比如CSS view 和image.

  component.js : component controller, 定义属性,集合,事件以及方法 穿进去的name 属性就是component所在的包名

  component.json: TODO

所有在component文件夹下的所有路径都是相对于component.js的相对路径, 而不是index.html文件.

一个完整的component目录如下:


参考:

http://www.cnblogs.com/jerrylu/p/4428966.html

http://www.07net01.com/2016/02/1280573.html

http://www.saplu.com/forum-39-1.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值