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.

最后的实现效果就是:

相关推荐
slacker-kian4 天前
[实践]-让 SAP 工程 Skill 脱离 opencode跑在自定义Agent 上
ai·llm·sap·agent·abap·adt·opencode
爱喝水的鱼丶4 天前
SAP-ABAP:MM 模块供应商主数据开发:字段扩展、分级管控与同步接口开发
开发语言·性能优化·接口·sap·abap·增强·经验交流
slacker-kian6 天前
本地大模型 + 自建 MCP Server + SAP OData:让 LLM 代理 SAP 业务操作
大模型·llm·sap·agent·mcp·odata
爱喝水的鱼丶6 天前
SAP-ABAP:SAP 权限控制深度解析:自定义程序与标准事务码的边界与协同
性能优化·sap·abap·权限·开发交流·交流学习
爱喝水的鱼丶8 天前
SAP-ABAP:MM 模块库存管理开发:出入库增强、批次管理与库存盘点功能开发
性能优化·sap·abap·增强·开发运维·经验交流·mm模块
goyeer9 天前
20.[SAP ABAP] DATA与TYPES异同
sap·abap·fico·fi·co·mm
爱喝水的鱼丶9 天前
SAP-ABAP:SAP MM 模块物料主数据批量导入与增强开发:字段扩展、校验逻辑与批量导入工具开发
开发语言·性能优化·sap·abap·增强·经验交流·mm
goyeer9 天前
21.[SAP ABAP] DATA关键字详解
sap·abap·fi·mm·opensql
修电脑的猫10 天前
在中国使用 Claude Code 解决 403 错误(VS CODE)
ai·sap
Henry-SAP10 天前
SAP PP模块核心机制解析
人工智能·云原生·sap·erp