wx.getSystemInfoSync(),//获取设备信息
try {
const res = wx.getSystemInfoSync()
console.log(res.model)
console.log(res.pixelRatio)
console.log(res.windowWidth)
console.log(res.windowHeight)
console.log(res.language)
console.log(res.version)
console.log(res.platform)
} catch (e) {
// Do something when catch error
}
/*
SDKVersion: "2.18.0"
batteryLevel: 100
benchmarkLevel: 1
brand: "devtools"
deviceOrientation: "portrait"
devicePixelRatio: 3
enableDebug: true
fontSizeSetting: 15
language: "zh_CN"
model: "iPhone 6/7/8 Plus"
pixelRatio: 3
platform: "devtools"
safeArea: {top: 20, left: 0, right: 414, bottom: 736, width: 414, …}
screenHeight: 736
screenWidth: 414
statusBarHeight: 20
system: "iOS 10.0.1"
version: "8.0.5"
windowHeight: 688
windowWidth: 414
*/
wx.getMenuButtonBoundingClientRect(),//时间胶囊位置信息
获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。
/*
bottom: 56
height: 32
left: 320
right: 407
top: 24
width: 87
*/
小程序获取顶部高度,设备信息和时间胶囊位置信息
最新推荐文章于 2025-04-17 14:19:06 发布