my.confirm displays a confirmation box with two buttons, allowing users to confirm or cancel an action. The success callback receives a result indicating which button was pressed.
my.confirm({
title: 'Tips',
content: 'Do you want to check the courier number: 1234567890?',
confirmButtonText: 'Inquire now',
cancelButtonText: 'Not needed',
success: (result) => {
my.alert({
title: `${result.confirm}`,
});
},
});
| Property | Type | Required | Description |
|---|---|---|---|
title | String | No | Title of the confirm box. |
content | String | No | Content of the confirm box. |
confirmButtonText | String | No | OK button text, which is "OK" by default. |
cancelButtonText | String | No | Cancel button text, which is "Cancel" by default. |
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Description |
|---|---|---|
confirm | Boolean | Click Confirm to return true; click Cancel to return false. |
result.confirm to determine which button was pressed:
true = Confirm button clickedfalse = Cancel button clickedmy.confirm({
title: 'Delete Item',
content: 'Are you sure you want to delete this item?',
success: (result) => {
if (result.confirm) {
console.log('User confirmed deletion');
// Proceed with deletion
} else {
console.log('User cancelled');
}
},
});
my.confirm({
title: 'Leave Page',
content: 'You have unsaved changes. Do you want to leave?',
confirmButtonText: 'Leave',
cancelButtonText: 'Stay',
success: (result) => {
if (result.confirm) {
// Navigate away
}
},
});