SAP UI5 walkthrough step5 Controllers

在这个章节,我们要做的是,将之前的text文本展示为一个按钮,并将声明绑定在点击按钮事件。

因为改的是外观,所以我们修改的是view.XML

webapp/view/App.view.xml

复制代码
<mvc:View
   controllerName="ui5.walkthrough.controller.App"
   xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc">
   <Button
      text="Say Hello"
      press=".onShowHello"/>
</mvc:View>

根据MVC架构原理,这种点击按钮事件,应该放在controller里面

所以我们这边要新建一个App.controller.js

webapp/controller/App.controller.js (New)

复制代码
sap.ui.define([
   "sap/ui/core/mvc/Controller"
], (Controller) => {
   "use strict";

   return Controller.extend("ui5.walkthrough.controller.App", {
      onShowHello() {
         // show a native JavaScript alert
         alert("Hello World");
      }
   });
});

Conventions

  • Controller names are capitalized

  • Controllers carry the same name as the related view (if there is a 1:1 relationship)

  • Event handlers are prefixed with on

  • Controller names always end with *.controller.js

最后输出的效果如下

相关推荐
goyeer1 天前
05.[SAP ABAP] ABAP中的运算符
算法·sap·abap·运算符
爱喝水的鱼丶16 天前
SAP-ABAP:SAP概述:数据处理的系统、应用与产品
运维·学习·sap·abap·1024程序员节
1314lay_100717 天前
SAP ABAP 导入excel表,导多个sheet
excel·abap
IT小白农民工20 天前
安装SAP Business one for HANA之前的准备
linux·经验分享·sap
寒武青锋20 天前
SAP 后台批量激活程序
sap·abap
LilySesy1 个月前
ABAP+在select的时候,可以A=B A=C B=C这样子JOIN吗?
数据库·sql·ai·excel·sap·abap
LilySesy1 个月前
ABAP+WHERE字段长度不一致报错解决
java·前端·javascript·bug·sap·abap·alv
海阔天空0921 个月前
ABAP S4 新语法 sql with 的用法demo
abap
LilySesy1 个月前
ABAP+如果在join的时候需要表1的字段某几位等于表2的字段的某几位,需要怎么做?
服务器·前端·数据库·sap·abap·alv
不想上班的小吕1 个月前
SAP EXCEL模板下载导入
excel·sap