我正在 Explored 中使用这个 MessageBox 演示。如何在按钮上绑定事件:MessageBox.Action.YES/“自定义按钮”?
在MessageBox.show api中,我只找到了onClose参数。
在我的 index.html 文件中,我有以下代码:
<script>
sap.ui.getCore().attachInit(function() {
jQuery.sap.registerModulePath("lodash","https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min");
jQuery.sap.require("lodash");
new sap.m.Shell({
app: new sap.ui.core.ComponentContainer({
height : "100%",
name : "sap.com.ml.docservicedoc-service-m-learning"
})
}).placeAt("content");
});
Run Code Online (Sandbox Code Playgroud)
我现在如何在我的控制器之一(而不是视图)中使用 lodash?我试过:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"lodash"], function(Controller, _) {
Run Code Online (Sandbox Code Playgroud)
不幸的是“_”始终是未定义的。
我正在使用 SAP UI5 1.52。我的格式化程序文件是一个单独的文件并加载到控制器中。但登录this格式化程序会返回视图实例而不是控件实例。
我之前曾提到过这个问题,并尝试使用绝对路径并更改了格式化程序中返回对象的方式。它抛出一个错误,指出找不到函数。
SAPUI5中处理模型时partsand有什么用?path
有人可以解释一下以下代码(invoiceJSONModel 在哪里)吗?
<mvc:View
controllerName="sap.ui.demo.walkthrough.controller.InvoiceList"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<List
headerText="{i18n>invoiceListTitle}"
class="sapUiResponsiveMargin"
width="auto"
items="{invoice>/Invoices}">
<items>
<ObjectListItem
title="{invoice>Quantity} x {invoice>ProductName}"
number="{
parts: [{path: 'invoice>ExtendedPrice'}, {path: 'view>/currency'}],
type: 'sap.ui.model.type.Currency',
formatOptions: {
showMeasure: false
}
}"
numberUnit="{view>/currency}"
numberState="{= ${invoice>ExtendedPrice} > 50 ? 'Error' : 'Success' }">
<firstStatus>
<ObjectStatus text="{
path: 'invoice>Status',
formatter: '.formatter.statusText'
}"/>
</firstStatus>
</ObjectListItem>
</items>
</List>
</mvc:View>
Run Code Online (Sandbox Code Playgroud) 在官方 UI5 文档中,有一个如何加载 a 的代码片段sap.ui.core.Fragment:
sap.ui.require(["sap/ui/core/Fragment"], async function(Fragment){
this.myFragment = await Fragment.load({
name: "my.useful.VerySimpleUiPart"
});
});
Run Code Online (Sandbox Code Playgroud)
同时,我可以sap.ui.core.Fragment使用 a loadFragmentof加载sap.ui.core.mvc.Controller:
this.myFragment = await this.loadFragment({
name: "my.useful.VerySimpleUiPart"
});
Run Code Online (Sandbox Code Playgroud)
thisBaseController是一个基于的实例sap.ui.core.mvc.Controller。
据我了解,在幕后loadFragment使用:sap.ui.core.Fragment.load
通过 加载片段
sap.ui.core.Fragment.load。
如果是这样,我们为什么需要Controller.loadFragment?SAP 有官方建议使用哪种方法吗?