swan.onAppShow

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

    callback返回参数说明 :

    referrerInfo 的结构

    扫码体验

    swan.onAppShow - 图5

    代码示例

    1. App({
    2. onLaunch: function () {
    3. swan.onAppShow(function(res) {
    4. console.warn('请在真机中进行中进行验证,在工具中点击工具栏的刷新按钮也可模拟onShow触发事件,开发者按照自己的业务逻辑进行监听,被触发时机和App.onShow一致。');
    5. swan.showModal({
    6. content: JSON.stringify(res),
    7. showCancel: false
    8. });
    9. console.log('path', res.path);
    10. console.log('shareTicket', res.shareTicket);
    11. console.log('referrerInfo', res.referrerInfo);
    12. console.log('entryType', res.entryType);
    13. console.log('appURL', res.appURL);
    14. });
    15. });
    • 在解析 query 的时候,基础库会使用decodeURIComponent对query的参数值进行一次解码,该功能将在未来的基础库版本下线,并提前通知开发者下线的基础库版本号;