alarms.get()
获取指定名称的闹钟。
这是一个返回 Promise
的异步函数。
语法
js
let getAlarm = browser.alarms.get(
name // 可选字符串
)
参数
name
可选-
string
。要获取的闹钟的名称。如果不提供此参数,将使用空字符串""
。
返回值
示例
js
function gotAlarm(alarm) {
if (alarm) {
console.log(alarm.name);
}
}
let getAlarm = browser.alarms.get("my-periodic-alarm");
getAlarm.then(gotAlarm);
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
get |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
备注:
此 API 基于 Chromium 的 chrome.alarms
API。