// 获取电池API navigator.getBattery().then(function(battery) { // 电池电量在0到1之间,因此我们将其乘以100得出百分比 console.log("电池电量: " +battery.level* 100 + "%"); });