Files
aistream-test/UTS 插件工程/uni_modules/uts-getbatteryinfo
2025-11-27 20:48:18 +08:00
..
2025-11-27 20:48:18 +08:00
2025-11-27 20:48:18 +08:00
2025-11-27 20:48:18 +08:00
2025-11-27 20:48:18 +08:00
2025-11-27 20:48:18 +08:00

uts-getbatteryinfo

使用文档


import getBatteryInfo from "@/uni_modules/uts-getbatteryinfo";  
// 获取电量信息
getBatteryInfo({  
	success(res) {  
		uni.showToast({  
			title: "当前电量:" + res.level + '%',  
			icon: 'none'  
		});  
	}  
})
				

参数

Object object

属性 类型 必填 说明
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

object.success 回调函数

属性 类型 说明
level number 设备电量,范围 1 - 100
isCharging boolean 是否正在充电中