基础库 3.60.2 开始支持,低版本需做兼容处理。
解释: 监听小程序切后台事件。该事件与 App.onHide 的回调时机一致。
Web 态说明 :由于 Web 态框架暂不支持当前是否进入前、后台的状态检测,因此 swan.onAppHide 不会执行。
Function callback
小程序切后台事件的回调函数。
扫码体验
代码示例
请使用百度APP扫码
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
App({onHide: function (res) {console.log('onHide', res)swan.showModal({title: 'res',content: JSON.stringify(res),showCancel: false});}});
在开发者工具中打开
在开发者工具中打开
在 WEB IDE 中打开
App({onLaunch() {swan.onAppHide(res => {swan.showModal({title: 'res',content: JSON.stringify(res)});console.log('app hide', res);});}});