my.offAppHide

Unlisten for the event that the mini program is switched to background from foreground.

Sample code

.axml

copy
<!-- .axml-->
<button size="default" onTap="offAppHideHanlder" type="primary">Unlisten for the event that the mini program is switched to background</button>

.js

copy
//.js
onLoad() {
    my.onAppHide(this.onAppHideHandler)
},
// The method of listening for the event that the mini program is switched to background from foreground
onAppHideHandler() {
    console.log('The method of listening for the event that the mini program is switched to background from foreground')
},
// The method of unlistening for the event that the mini program is switched to background from foreground
offAppHideHanlder() {
    my.offAppHide(this.onAppHideHandler)
},

Parameters

The parameter is in object type and has the following property:

Property

Type

Description

callback

Function

The callback function for the event that the mini program is switched to background.