commands.reset()
将给定命令的描述和快捷键重置为扩展的 commands
manifest.json 键中指定的值。
这有效地撤销了使用 commands.update()
函数对命令所做的任何更改。
这是一个返回 Promise
的异步函数。
语法
js
browser.commands.reset(
name // 字符串
);
参数
name
-
string
。要重置的命令的名称,给定commands.Command
对象的name
属性。
返回值
一个 Promise
,当快捷键已重置时其会兑现且无任何参数。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
reset |
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.
示例
当用户点击“reset”按钮时重置名为“my-command”的命令:
js
const commandName = "my-command";
function resetShortcut() {
browser.commands.reset(commandName);
}
document.querySelector("#reset").addEventListener("click", resetShortcut);