uni.getBatteryInfo(options)
获取电池电量信息
本 API 是 uni ext api,需下载插件:uni-getbatteryinfo
Parameters
GetBatteryInfoOptions Values
| name | type | optinal | default | description |
| success | (res: GetBatteryInfoSuccess) => void | NO | - | 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | (res: UniError) => void | NO | - | 接口调用失败的回调函数 |
| complete | (res: any) => void | NO | - | 接口调用成功的回调 |
GetBatteryInfoSuccess Values
| name | type | optinal | default | description |
| errMsg | string | YES | - | - |
| level | number | YES | - | 设备电量,范围1 - 100 |
| isCharging | boolean | YES | - | 是否正在充电中 |
getBatteryInfo Compatibility
| Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x |
| 4.4.4 | 3.6.11 | 3.9.0 | 9.0 | 3.6.11 | 3.9.0 |
See also
Related Bug
uni.getBatteryInfoSync()
获取电池电量信息
本 API 是 uni ext api,需下载插件:uni-getbatteryinfo
Return value
GetBatteryInfoResult Values
| name | type | optinal | default | description |
| level | number | YES | - | 设备电量,范围1 - 100 |
| isCharging | boolean | YES | - | 是否正在充电中 |
getBatteryInfoSync Compatibility
| Android version | Android uni-app | Android uni-app-x | iOS version | iOS uni-app | iOS uni-app-x |
| 4.4.4 | 3.6.11 | 3.9.0 | 9.0 | 3.6.11 | 3.9.0 |
See also
Related Bug
Example
hello uni-app x
General type
GeneralCallbackResult
| name | type | optinal | default | description |
| errMsg | string | YES | - | 错误信息 |