# uni.getBatteryInfo(options)

获取电池电量信息

本 API 是 uni ext api,需下载插件:uni-getbatteryinfo

# 参数

名称 类型 必填 默认值 描述
options GetBatteryInfoOptions -
名称 类型 必备 默认值 描述
success (res: GetBatteryInfoSuccess) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
fail (res: UniError) => void - 接口调用失败的回调函数
complete (res: any) => void - 接口调用成功的回调
# GetBatteryInfoSuccess 的属性值
名称 类型 必备 默认值 描述
errMsg string - -
level number - 设备电量,范围1 - 100
isCharging boolean - 是否正在充电中

# getBatteryInfo 兼容性

Android iOS web
3.9.0 4.11 -

# 参见

相关 Bug

# uni.getBatteryInfoSync()

获取电池电量信息

本 API 是 uni ext api,需下载插件:uni-getbatteryinfo

# 返回值

类型
GetBatteryInfoResult
名称 类型 必备 默认值 描述
level number - 设备电量,范围1 - 100
isCharging boolean - 是否正在充电中

# getBatteryInfoSync 兼容性

Android iOS web
3.9.0 4.11 -

# 参见

相关 Bug

# 示例

hello uni-app x

Template

Script

<template>
	<view>
		<text>当前电量:{{level}}%</text>
		<text>是否充电中:{{isCharging}}</text>
	</view>
</template>


<style>

</style>

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 描述
errMsg string - 错误信息