Javascript 事件“;按「;在sap.m.CustomListItem上,项目不';行不通
显示CustomListItem有一个Javascript 事件“;按「;在sap.m.CustomListItem上,项目不';行不通,javascript,sapui5,Javascript,Sapui5,显示CustomListItem有一个按事件 我创建了一个站点,在列表项上有一个press事件,在列表项内的一个按钮上有另一个press事件。这个按钮很好用。单击列表项不会显示任何内容。甚至一个错误都没有 var oCustomItem = new sap.m.CustomListItem({ content: [ new sap.m.Text({ text: "{text}"}), new sap.m.Button({
按事件
我创建了一个站点,在列表项上有一个press事件,在列表项内的一个按钮上有另一个press事件。这个按钮很好用。单击列表项不会显示任何内容。甚至一个错误都没有
var oCustomItem = new sap.m.CustomListItem({
content: [
new sap.m.Text({
text: "{text}"}),
new sap.m.Button({
text: "btn",
press: function(){
alert("Pressed the button");
}
})
],
press: function(){
alert("Clicked the list item");
}
});
以下是一个例子:
这是人们在使用列表控件时经常遇到的问题。这有一个答案
简言之,您必须将类型
属性添加到自定义列表项
:
var oCustomItem = new sap.m.CustomListItem({
content: [
new sap.m.Text({
text: "{text}"}),
new sap.m.Button({
text: "btn",
press: function(){
alert("Pressed the button");
}
})
],
type : sap.m.ListType.Active,
press: function(){
alert("Clicked the list item");
}
});
或者将mode
属性添加到您的sap.m.List
。有关比较,请参见上面提到的答案