-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
zh-CN: create
omnibox.onInputStarted
(#25084)
- Loading branch information
1 parent
5899829
commit 3d845e5
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
files/zh-cn/mozilla/add-ons/webextensions/api/omnibox/oninputstarted/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: omnibox.onInputStarted | ||
slug: Mozilla/Add-ons/WebExtensions/API/omnibox/onInputStarted | ||
l10n: | ||
sourceCommit: b8a0743ca8b1e1b1b1a95cc93a4413c020f11262 | ||
--- | ||
|
||
{{AddonSidebar}} | ||
|
||
当用户开始与扩展交互(在地址栏输入扩展的关键词以及一个空格)时触发。 | ||
|
||
这个事件将在任何 {{WebExtAPIRef("omnibox.onInputChanged")}} 事件之前发送。 | ||
|
||
## 语法 | ||
|
||
```js-nolint | ||
browser.omnibox.onInputStarted.addListener(listener) | ||
browser.omnibox.onInputStarted.removeListener(listener) | ||
browser.omnibox.onInputStarted.hasListener(listener) | ||
``` | ||
|
||
事件有三个函数: | ||
|
||
- `addListener(listener)` | ||
- : 为此事件添加监听器。 | ||
- `removeListener(listener)` | ||
- : 停止监听此事件。`listener` 参数是要移除的监听器。 | ||
- `hasListener(listener)` | ||
- : 检查是否已为此事件注册了 `listener`。若正在监听,返回 `true`,否则返回 `false`。 | ||
|
||
## addListener 语法 | ||
|
||
### 参数 | ||
|
||
- `listener` | ||
- : 当此事件发生时调用的函数。该函数不需要传递任何参数。 | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} | ||
|
||
## 示例 | ||
|
||
```js | ||
browser.omnibox.onInputStarted.addListener(() => { | ||
console.log("用户已经开始交互"); | ||
}); | ||
``` | ||
|
||
{{WebExtExamples}} | ||
|
||
> [!NOTE] | ||
> 该 API 基于 Chromium 的 [`chrome.omnibox`](https://developer.chrome.google.cn/docs/extensions/reference/api/omnibox) API。 |