SAP UI5 XML视图中的控制语句(如果有)
我有一个技术上的疑问 在XML视图中,我们如何使用控制语句?例如,如果其他。我有一个条件,如果它被满足,一些不同的代码行应该被呈现。我查过了,可以找到预处理器指令: 代码:SAP UI5 XML视图中的控制语句(如果有),xml,sapui5,Xml,Sapui5,我有一个技术上的疑问 在XML视图中,我们如何使用控制语句?例如,如果其他。我有一个条件,如果它被满足,一些不同的代码行应该被呈现。我查过了,可以找到预处理器指令: 代码: 但是,“模板”的名称空间(xmlns:template=)http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1)不再存在 有人知道如何让它工作吗?我不想使用三元运算符,这在场景中是不可行的。您可以使用visible属性。然后,控件将被渲染但不显示。
但是,“模板”的名称空间(xmlns:template=)http://schemas.sap.com/sapui5/extension/sap.ui.core.template/1)不再存在
有人知道如何让它工作吗?我不想使用三元运算符,这在场景中是不可行的。您可以使用visible属性。然后,控件将被渲染但不显示。 格式化程序使未定义或空的条件更易于读取 XML:
我很感激你的回答,但光是能见度并不是我想要的。我担心SAP UI5中不支持简单的控制语句,例如,我们可以在JSP中轻松地做到这一点!
<template:if test="{meta>ImageUrl}">
<template:then>
<Image src="{path: 'meta>ImageUrl', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
</template:then>
<template:else>
<Text text="{path: 'meta>Title/Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
</template:else>
</template:if>
<Image visible="{ path: 'meta>ImageUrl', formatter: '.Formatter.visible' }" src="{path: 'meta>ImageUrl', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
<Text visible="{ path: 'meta>ImageUrl', formatter: '.Formatter.visible' }" text="{path: 'meta>Title/Value', formatter: 'sap.ui.model.odata.AnnotationHelper.format'}" />
visible : function(value) {
return !(typeof(value) === 'undefined' || value === null);
}