获取小游戏冷启动时的参数。生命周期内返回值始终不变。
wx.getLaunchOptionsSync()
hostExtraData
返回冷启动参数。
2.5.0
const launchOptions = getLaunchOptionsSync();console.log('冷启动场景值:', launchOptions.scene);console.log('冷启动 query:', launchOptions.query);// 仅小游戏环境有实际值console.log('宿主数据:', launchOptions.hostExtraData?.host_scene); Copy
const launchOptions = getLaunchOptionsSync();console.log('冷启动场景值:', launchOptions.scene);console.log('冷启动 query:', launchOptions.query);// 仅小游戏环境有实际值console.log('宿主数据:', launchOptions.hostExtraData?.host_scene);
获取小游戏冷启动时的参数。生命周期内返回值始终不变。
wx.getLaunchOptionsSync(),包含hostExtraData等完整字段。hostExtraData无实际值。