-
Notifications
You must be signed in to change notification settings - Fork 8.3k
[zh-cn]: translate CommandEvent constructor #30595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,47 @@ | ||
| --- | ||
| title: CommandEvent:CommandEvent() 构造函数 | ||
| slug: Web/API/CommandEvent/CommandEvent | ||
| l10n: | ||
| sourceCommit: 66ca26b10d8a8d7c8c287728cd60108b65a1f331 | ||
| --- | ||
|
|
||
| {{APIRef("Invoker Commands API")}} | ||
|
|
||
| **`CommandEvent()`** 构造函数用于创建一个新的 {{domxref("CommandEvent")}} 对象。 | ||
|
|
||
| ## 语法 | ||
|
|
||
| ```js-nolint | ||
| new CommandEvent(type) | ||
| new CommandEvent(type, options) | ||
| ``` | ||
|
|
||
| ### 参数 | ||
|
|
||
| - `type` | ||
| - : 表示事件名称的字符串。区分大小写;浏览器会将其设置为 `command`。 | ||
| - `options` {{optional_inline}} | ||
| - : 一个对象,除 {{domxref("Event/Event", "Event()")}} 中定义的属性外,还可以包含下列属性: | ||
xyy94813 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `source` {{optional_inline}} | ||
| - : 一个 {{domxref("HTMLButtonElement")}},表示触发该事件的按钮。虽然可以使用任意元素作为 source,但建议仅使用按钮以避免意外行为。 | ||
xyy94813 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - `command` {{optional_inline}} | ||
| - : 一个字符串,表示受控元素应执行的命令。手动创建 `CommandEvent` 时可以使用任意字符串,但建议使用内置名称或以两个连字符 (`--`) 为前缀,以确保向前兼容。 | ||
xyy94813 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 返回值 | ||
|
|
||
| 新的 {{domxref("CommandEvent")}} 对象。 | ||
|
|
||
| ## 规范 | ||
|
|
||
| {{Specifications}} | ||
|
|
||
| ## 浏览器兼容性 | ||
|
|
||
| {{Compat}} | ||
|
|
||
| ## 参见 | ||
|
|
||
| - {{domxref("Invoker Commands API", "调用者命令 API", "", "nocode")}} | ||
| - {{domxref("HTMLButtonElement.command")}} | ||
| - {{domxref("HTMLButtonElement.commandForElement")}} | ||
| - {{domxref("CommandEvent")}} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.