dlt.enableAlertBeforeUnload
Introduction
Enables the confirmation dialog that appears when leaving a page in the mini-program.
Conditions for the Dialog
- When the user is on a non-homepage page within the mini-program
- When using the official navigation bar's "Back" button
- When using a custom back button in full-screen mode
- When pressing the Android system's back button
Important Notes
- The gesture-based back navigation is not intercepted.
- In any scenario, this feature should not prevent users from exiting the mini-program.
Parameters
Object object
Property | Type | Default | Required | Description |
---|---|---|---|---|
message | String | Yes | Confirmation dialog message |
Sample Code
Page({
onReady() {
dlt.enableAlertBeforeUnload({
message: 'Are you sure you want to leave?',
success: function (res) {},
fail: function (res) {},
complete: function (res) {},
});
},
});