logo
  • 教程列表
  • SO官方文檔
  • 電池狀態 API
    • 電池事件
    • 獲得當前的電池電量
    • 電池充電
    • 留出時間,直到電池耗盡
    • 留出時間,直到電池充滿電
  1. StackOverflow 文件
  2. JavaScript 教程
  3. 電池狀態 API
  4. 獲得當前的電池電量

獲得當前的電池電量

Created: November-22, 2018

// Get the battery API
navigator.getBattery().then(function(battery) {
    // Battery level is between 0 and 1, so we multiply it by 100 to get in percents
    console.log("Battery level: " + battery.level * 100 + "%");
});
  • 電池充電
  • 電池事件

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明