my.offAppHide
Updated at:
Removes a listener registered for the Mini Program background event.
Description
my.offAppHide removes a previously registered listener for the event that fires when the Mini Program switches to the background. Pass the same function reference used in my.onAppHide to remove that specific listener.
Parameters
|
Property |
Type |
Required |
Description |
|
listener |
Function |
No |
The callback function for the background event of the Mini Program. |
Sample code
The following example registers a listener for the background event and then removes it.
const onAppHideHandler = () => {
console.log('How to switch the listener to the background');
};
// Register the listener.
my.onAppHide(onAppHideHandler);
// Remove the listener using the same function reference.
my.offAppHide(onAppHideHandler);
Is this page helpful?