SAP UI5 walkthrough step3 Controls

在上一步,我们是直接用index.html 中的body 里面的DIVision去输出 hello world,

在这个章节,我们将用SAP UI5 的标准控件 sap/m/Text

首先,我们去修改 webapp/index.html

html 复制代码
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>UI5 Walkthrough</title>
	<script
		id="sap-ui-bootstrap"
		src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
		data-sap-ui-theme="sap_horizon"
		data-sap-ui-libs="sap.m"
		data-sap-ui-compatVersion="edge"
		data-sap-ui-async="true"
		data-sap-ui-onInit="module:ui5/walkthrough/index"
		data-sap-ui-resourceroots='{
			"ui5.walkthrough": "./"
		}'>

	</script>
</head>
<body class="sapUiBody" id="content">  
</body>
</html>

index.html 这个文件中指明了,我们要先去加载index.js 文件

所以我们在index.js 中需要去实例化 content

webapp/index.js

html 复制代码
sap.ui.define([
	"sap/m/Text"
], (Text) => {
	"use strict";

	new Text({
		text: "Hello World"
	}).placeAt("content");
});

Instead of using native JavaScript to display a dialog we want to use a simple SAPUI5 control. Controls are used to define appearance and behavior of parts of the screen.

In the example above, the callback of the init event is where we now instantiate a SAPUI5 text control. The name of the control is prefixed by the namespace of its control library sap/m/ and the options are passed to the constructor with a JavaScript object. For our control we set the text property to the value "Hello World".

We chain the constructor call of the control to the standard method placeAt that is used to place SAPUI5 controls inside a node of the document object model (DOM) or any other SAPUI5 control instance. We pass the ID of a DOM node as an argument. As the target node we use the body tag of the HTML document and give it the ID content.

All controls of SAPUI5 have a fixed set of properties, aggregations, and associations for configuration. You can find their descriptions in the Demo Kit. In addition, each control comes with a set of public functions that you can look up in the API reference.

最后的实现效果就是:

相关推荐
数字化转型20257 天前
Alternative Reconciliation Accounts 备选统驭科目
sap
小九不懂SAP18 天前
6、定义字段状态变式
sap·s4
lu_rong_qq1 个月前
SAP B1 三大基本表单标准功能介绍-物料主数据(下)
数据库·sap·erp
1314lay_10071 个月前
FUNCTION_ALV 下拉框的实现
abap
Fireworks_me1 个月前
SAP 有趣的‘bug‘ 选择屏幕输入框没了
abap
仁,义1 个月前
其它特殊库存
sap·库存管理·特殊库存
李安迪是大神1 个月前
上传PDF、DOC文件到SAP HCM系统中案例
pdf·word·sap·abap·sap erp
集信通1 个月前
SAP和致远OA系统集成案例
人工智能·自动化·区块链·sap
数字化转型20252 个月前
SAP BRIM用于应收账款AR收入中台
大数据·microsoft·sap
荀彧原名苟或2 个月前
SAP MIGO屏幕增强的具体实施步骤介绍(SE19:MB_MIGO_BADI) <转载>
java·数据库·缓存·sap·abap