get-battery-info.uvue 400 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<template>
	<view>
		<text>当前电量:{{level}}%</text>
		<text>是否充电中:{{isCharging}}</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				level: 0,
				isCharging: false
			}
		},
		onLoad() {
			uni.getBatteryInfo({
				success: res => {
					this.level = res.level;
					this.isCharging = res.isCharging;
				}
			});
		}
	}
</script>
<style>

</style>