my.alert displays an alert box with customizable title, content, and button text. This is a modal dialog that requires user interaction to dismiss.
my.alert({
title: 'Tips',
content: 'Your bill for this month has been released',
buttonText: 'Show',
success: () => {
my.alert({
title: 'Click "Show"',
});
},
});
| Property | Type | Required | Description |
|---|---|---|---|
title | String | No | Title of the alert box. |
content | String | No | Contents of the alert box. |
buttonText | String | No | Button text, which is OK 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). |
buttonText is not specifiedmy.confirm for two-button dialogs)success callback is triggered when the user taps the buttonmy.alert({
title: 'Payment Successful',
content: 'Your order has been processed',
});
my.alert({
title: 'Notification',
content: 'You have a new message',
buttonText: 'View',
success: () => {
console.log('User clicked View');
},
});