提交 1ac5023b 编写于 作者: W wanganxp

补充电量模块异常的报错提示

上级 775ef9eb
<template> <template>
<view> <view>
<text>当前电量:{{level}}%</text> <text>当前电量:{{level}}%</text>
<text>是否充电中:{{isCharging}}</text> <text>是否充电中:{{isCharging}}</text>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
level: 0, level: 0,
isCharging: false isCharging: false
} }
}, },
onLoad() { onLoad() {
uni.getBatteryInfo({ try {
success: res => { uni.getBatteryInfo({
this.level = res.level; success: res => {
this.isCharging = res.isCharging; this.level = res.level;
} this.isCharging = res.isCharging;
}); }
} });
} } catch (e) {
console.error(e.message);
uni.showModal({
content: e.message,
showCancel: false
});
}
}
}
</script> </script>
<style>
</style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册