如下:
const actionSheet = await this.actionSheetController.create({
header: moreText,
buttons: [
{
text: stockText,
handler: () => {
this.stockConfirm(item);
},
},
// 在数组中使用三目运算符
item.state === 20 ?
{
text: viewFailedText,
handler: () => {
this.sendFailed(item, true);
},
} : {
text: failedText,
handler: () => {
this.sendFailed(item);
},
},
{
text: cancelText,
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
},
},
]
});