如何在SAPUI5中更改css类运行时
我有一块定制的瓷砖。我想在HBox顶部添加类/更改颜色,它现在是浅绿色。因此,颜色应根据下面所示的红色、棕色、深绿色或浅绿色。如果分数高于80,则应为深绿色。我该怎么做。你可以这样做:-如果我们有静态id,这就可以了如何在SAPUI5中更改css类运行时,sapui5,Sapui5,我有一块定制的瓷砖。我想在HBox顶部添加类/更改颜色,它现在是浅绿色。因此,颜色应根据下面所示的红色、棕色、深绿色或浅绿色。如果分数高于80,则应为深绿色。我该怎么做。你可以这样做:-如果我们有静态id,这就可以了 $("#hbox_id").toggleClass('change_me newClass'); 您可以将CSS与指定给HBox控件的自定义数据一起使用。格式化程序将帮助根据该值为HBox分配适当的类 XML: CSS: 问题是我没有使用jquery,它的SAPUI5框架, &l
$("#hbox_id").toggleClass('change_me newClass');
您可以将CSS与指定给HBox控件的自定义数据一起使用。格式化程序将帮助根据该值为HBox分配适当的类 XML: CSS:
问题是我没有使用jquery,它的SAPUI5框架,
<HBox width="200px" height="150px" backgroundDesign="Solid" >
<items>
...
</items>
<customData>
<core:CustomData
key="style-class"
value="{path:'/props/DLES', formatter:'.formatter.formatStyle'}"
writeToDom="true"/>
</customData>
</HBox>
formatStyle : function(v){
if(v>80){
return "darkgreen";
}
else if(v > 60){
return "green"
}
else if(v > 50){
return "yellow"
}
else if(v > 40){
return "brown"
}
else{
return "red"
}
}
[data-style-class=darkgreen] {
background-color: #01870e !important
}
[data-style-class=green] {
background-color: #7fc257 !important
}
[data-style-class=yellow] {
background-color: #ffc300 !important
}
[data-style-class=brown] {
background-color: #b73209 !important
}
[data-style-class=red] {
background-color: #e00404!important
}