标题取决于 SAPUI5 中的其他变量 [英] Title depending on other variable in SAPUI5
问题描述
有时当我想显示某些东西并隐藏其他东西时,我会这样做:visible={some_variable}
例如
.现在我必须处理 Dialog
标题我的意思是:我想根据其他变量做一些事情 - 如果 variable
是 title="{i18n>a}"
并且如果 variable
是b 然后 title="{i18n>b}"
.我该怎么做?
Sometimes when I want to show something and hide other thing I just do:
visible={some_variable}
for example <Column visible={some_variable}>
. Now I have to deal with Dialog
title I mean:
I would like to do something depending on other variable - if variable
is a then title="{i18n>a}"
and if variable
is b then title="{i18n>b}"
. How can I do that?
推荐答案
三元运算符适用于 sapui5 绑定.所以在这种情况下,你可以这样做:
The ternary operator works in sapui5 bindings. So in this case, you could do:
<Dialog title="{= ${variable} === 'A' ? ${i18n>a} : ${i18n>b} }" />
如果它变得更复杂,格式化程序可能是更好的解决方案.
If it gets more complicated, a formatter might be a better solution.
这篇关于标题取决于 SAPUI5 中的其他变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!