swan.onAppShow

兼容处理。 解释: 监听小程序切前台事件。该事件与 App.onShow 的回调参数一致。

方法参数

function callback小程序切前台事件的回调函数。 callback返回参数说明 :

Object res 返回的对象信息

referrerInfo 的结构

entryType 的取值说明

示例

扫码体验

请使用百度APP扫码

图片示例

代码示例

  • 在开发者工具中预览效果
    1. // app.jsApp({ onShow: function (res) { console.log('onShow', res) swan.showModal({ title: 'res', content: JSON.stringify(res), showCancel: false }); }});
  • 在开发者工具中预览效果
    1. // app.jsApp({ onLaunch: function () { swan.onAppShow(function(res) { console.warn('请在真机中进行中进行验证,在工具中点击工具栏的刷新按钮也可模拟onShow触发事件,开发者按照自己的业务逻辑进行监听,被触发时机和App.onShow一致。'); swan.showModal({ title: 'res', content: JSON.stringify(res), showCancel: false }); console.log('scene', res.scene); console.log('path', res.path); console.log('query', res.query); console.log('shareTicket', res.shareTicket); console.log('referrerInfo', res.referrerInfo); console.log('entryType', res.entryType); console.log('appURL', res.appURL); }); }});

    Bug&Tip

  • -