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

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

上级 775ef9eb
<template>
<view>
<text>当前电量:{{level}}%</text>
<text>是否充电中:{{isCharging}}</text>
</view>
<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;
}
});
}
}
export default {
data() {
return {
level: 0,
isCharging: false
}
},
onLoad() {
try {
uni.getBatteryInfo({
success: res => {
this.level = res.level;
this.isCharging = res.isCharging;
}
});
} catch (e) {
console.error(e.message);
uni.showModal({
content: e.message,
showCancel: false
});
}
}
}
</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.
先完成此消息的编辑!
想要评论请 注册