单击时如何更改图像按钮?它应该改为其他图像按钮。
var offButton = new sap.ui.commons.Button({
id : "offIcon",
icon : "img/off.png" ,
press :function(e) {
alert("clicked");
var noButton = new sap.ui.commons.Button({
id:"noIcon",
icon : "img/no.png" ,
});
noImage.addStyleClass("noButtonImage");
答案 0 :(得分:0)
您正在定义两个按钮,这可能不起作用,请检查:
var offButton = new sap.ui.commons.Button({
id : "offIcon",
icon : "img/off.png" ,
press :function(e) {
var myBtn = sap.ui.getCore().byId("offIcon");
myBtn.setIcon(''); // this removes the icon
}
});
开关示例:
var offButton = new sap.ui.commons.Button({
id : "offIcon",
icon : "img/off.png" ,
press :function(e) {
var myBtn = sap.ui.getCore().byId("offIcon");
if (myBtn.getIcon() == '' || myBtn.getIcon == 'null') {
myBtn.setIcon('img/off.png');
} else {
myBtn.setIcon(''); // this removes the icon
}
}
});