my.offAppShow

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

Sample code

.axml

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

.js

copy
//.js
onLoad() {
    my.onAppShow(this.onAppShowHandler)
},
//The method of listening for the event that the mini program is switched to foreground from background
onAppShowHandler() {
    console.log('The mini program is switched to foreground from background')
},
//The method of unlistening for the event that the mini program is switched to foreground from background
offAppShowHanlder() {
    my.offAppShow(this.onAppShowHandler)
},
apphide() {
    console.log('The mini program is switched to background from foreground')
}

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 foreground.