mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-09-13 00:50:40 +08:00
1.6 KiB
1.6 KiB
设备信息 API
概述
设备信息 API 用于获取设备系统信息、网络状态等。
API 列表
uni.getSystemInfo
获取系统信息。
详细文档:https://doc.dcloud.net.cn/uni-app-x/api/system/system-info.html#getsysteminfo
返回值:
brand- 手机品牌model- 手机型号pixelRatio- 设备像素比screenWidth- 屏幕宽度screenHeight- 屏幕高度windowWidth- 可使用窗口宽度windowHeight- 可使用窗口高度statusBarHeight- 状态栏的高度language- 应用设置的语言version- 版本号platform- 平台
示例:
uni.getSystemInfo({
success: (res) => {
console.log('屏幕宽度', res.screenWidth)
console.log('屏幕高度', res.screenHeight)
console.log('状态栏高度', res.statusBarHeight)
}
})
uni.getSystemInfoSync
同步获取系统信息。
详细文档:https://doc.dcloud.net.cn/uni-app-x/api/system/system-info.html#getsysteminfosync
uni.getNetworkType
获取网络类型。
详细文档:https://doc.dcloud.net.cn/uni-app-x/api/system/network.html#getnetworktype
返回值:
networkType- 网络类型(wifi、2g、3g、4g、unknown、none)
uni.onNetworkStatusChange
监听网络状态变化。
详细文档:https://doc.dcloud.net.cn/uni-app-x/api/system/network.html#onnetworkstatuschange