pc端的微信打开小程序 uni-app 中 uni.getsysteminfosync() 中 deviceType 的值是 phone
pc端的微信打开小程序 uni-app 中 uni.getsysteminfosync() 中 deviceType 的值是 phone
2 回复
测试下原生微信小程序返回的值是否正确,如有问题请向微信开发者社区反馈。
更多关于pc端的微信打开小程序 uni-app 中 uni.getsysteminfosync() 中 deviceType 的值是 phone的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在PC端微信打开小程序时,uni.getSystemInfoSync()
返回的deviceType
为phone
是预期行为。这是因为微信小程序的运行环境识别机制决定的:
- 微信PC端的小程序实际上是运行在模拟的手机环境中,因此系统信息API会返回手机相关的参数
deviceType
这个字段反映的是小程序运行环境的模拟设备类型,而非实际的物理设备- 如果需要区分实际运行平台,可以结合
platform
字段来判断:- PC端微信:
platform: 'windows'
- Mac端微信:
platform: 'mac'
- PC端微信:
如果需要针对PC端做特殊处理,建议使用以下判断逻辑:
const systemInfo = uni.getSystemInfoSync();
const isPCWechat = systemInfo.platform === 'windows' || systemInfo.platform === 'mac';