弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
battery
只读特性返回
BatteryManager
which provides information about the system's battery charge level and whether the device is charging and exposes events that fire when these parameters change. This interface was introduced in early drafts of the
Battery Status API
and but has been replaced with
Promise
-based
Navigator.getBattery()
.
battery
property has been removed in favor of the standard
Navigator.getBattery()
method, which returns a battery
Promise
.
var battery = navigator.battery;
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
battery
弃用
|
Chrome
20 — 29
Prefixed
|
Edge No |
Firefox
16 — 50
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
16 — 50
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
不支持
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。
要求使用供应商前缀或不同名称。
Navigator.getBattery()
Navigator
activeVRDisplays
appCodeName
appName
appVersion
battery
buildID
clipboard
connection
cookieEnabled
credentials
deviceMemory
doNotTrack
geolocation
keyboard
语言
languages
locks
maxTouchPoints
mediaDevices
mediaSession
onLine
oscpu
permissions
platform
product
productSub
serviceWorker
userAgent
vendor
vendorSub
webdriver
xr