使用明文scheme打开小程序链接格式如下:
function toMiniProgram() {
// 小程序的appid和path
var appid = 'xxxxxxxxxx'; // 替换为你的小程序appid
var path = 'pages/home/doorList/doorList'; // 替换为你的小程序页面路径
var query = encodeURIComponent('mid=2'); // 替换为你的小程序页面参数
var env_version = 'trial'; // 替换为你的小程序环境版本
console.log(appid, path, query, env_version);
location.href = `weixin://dl/business/?appid=${appid}&path=${path}&query=${query}&env_version=${env_version}`;
}
使用跳转到小程序后,onLaunch中使用uni.getSystemInfo获取信息时会报错:
<TypeError: Cannot read properties of undefined (reading 'uid')>
TypeError: Cannot read properties of undefined (reading 'uid')
at mn.onLaunch (https://usr/app-service.js:5912:932)
at Ne (https://usr/app-service.js:5934:11399)
at e.__call_hook (https://usr/app-service.js:5934:45049)
at d.default.__call_hook (https://usr/app-service.js:5959:101252)
at Rt.onLaunch (https://usr/app-service.js:5959:103296)
at Rt.<anonymous> (https://lib/WASubContext.js:1:445841)
at new Rt (https://lib/WASubContext.js:1:447216)
at Function.<anonymous> (https://lib/WASubContext.js:1:447342)
at https://lib/WASubContext.js:1:422167
at Tt (https://usr/app-service.js:5959:103900)
但是在其他场景值进入小程序时都能正常获取uni.getSystemInfo的数据,也没有使用到报错中的uid参数,而且开发工具与pc端小程序均无次问题,仅手机使用浏览器跳转时会出现该问题,使用的是安卓设备,ios未知,现在需要该函数获取设备状态栏高度,请问要如何解决?
试试wx.getWindowInfo,getSystemInfo没维护了