getAll()
获取你已使用 commands
manifest.json 键注册的所有扩展命令。
该命令会返回一个 commands.Command
对象的数组。或者,如果你使用基于 promise 版本的 API——browser.commands.getAll()
,该命令将被传递到 Promise.then()
的 onFulfilled
参数中。
这是一个返回 Promise
的异步函数。
语法
js
let getCommands = browser.commands.getAll();
参数
无。
返回值
一个 Promise
,其会兑现一个包含 commands.Command
对象的数组,每个对象对应扩展注册的一个命令。如果没有注册命令,数组将为空。
示例
js
function logCommands(commands) {
commands.forEach((command) => {
console.log(command);
});
}
let getCommands = browser.commands.getAll();
getCommands.then(logCommands);
示例扩展
备注:
此 API 基于 Chromium 的 chrome.commands
API。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getAll |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No 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.