Dscription
my.onAppShow
Listen for the foreground event of the mini program.
Calling this interface is actually the callback of dynamically registering app.js registering Mini Program lifecycle event, and the interface of cancelling listening is my.offAppShow.
Input parameter
Function listener
Parameter
Object res
Property | Type | Description |
path | String | The path (code package path) to start the mini program. |
scene | Number | The scenario value that starts the mini program. |
query | Object | The query parameters used to start the mini program. |
referrerInfo | Object | The source message. Important This field may be undefined on the base library of earlier version. Therefore, When accessing its properties, please perform null check first, such as: |
apiCategory | string | The API category. |
referrerInfo
Property | Type | Description |
appId | String | The source mini program. |
extraData | Object | The data that source mini program passed through |
apiCategory
Enumerator | Description | Compatibility |
default | The default type. | - |
embedded | Returns when the mini program is opened in half-screen mode. | Basic library: 2.7.22 + |
Sample code
my.onAppShow(Function listener)
const onAppShowHandler = (res) => {
console.log('onAppShow:', res)
};
my.onAppShow(onAppShowHandler);