swan.onAppShow
解释: 监听小程序切前台事件。该事件与 App.onShow 的回调参数一致。
callback返回参数说明 :
referrerInfo 的结构
扫码体验
代码示例
- 示例一:在onShow中使用在开发者工具中预览效果
App({
onLaunch: function () {
swan.onAppShow(function(res) {
console.warn('请在真机中进行中进行验证,在工具中点击工具栏的刷新按钮也可模拟onShow触发事件,开发者按照自己的业务逻辑进行监听,被触发时机和App.onShow一致。');
swan.showModal({
content: JSON.stringify(res),
showCancel: false
});
console.log('path', res.path);
console.log('shareTicket', res.shareTicket);
console.log('referrerInfo', res.referrerInfo);
console.log('entryType', res.entryType);
console.log('appURL', res.appURL);
});
});
- 在解析 query 的时候,基础库会使用decodeURIComponent对query的参数值进行一次解码,该功能将在未来的基础库版本下线,并提前通知开发者下线的基础库版本号;