-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[zh-cn]: add translation for
PermissionStatus.change_event
(#19770)
- Loading branch information
1 parent
eea0a55
commit f9fa852
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
files/zh-cn/web/api/permissionstatus/change_event/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,45 @@ | ||
--- | ||
title: PermissionStatus:change 事件 | ||
slug: Web/API/PermissionStatus/change_event | ||
l10n: | ||
sourceCommit: ee253ac58d71b2ed336b705ab97dbe93122b3e04 | ||
--- | ||
|
||
{{APIRef("Permissions API")}}{{AvailableInWorkers}} | ||
|
||
{{domxref("PermissionStatus")}} 接口的 **`change`** 事件在 {{domxref("PermissionStatus.state")}} 属性发生更改时触发。 | ||
|
||
## 语法 | ||
|
||
在 {{domxref("EventTarget.addEventListener", "addEventListener()")}} 等方法中使用事件名称,或设置事件处理器属性。 | ||
|
||
```js | ||
addEventListener("change", (event) => {}); | ||
|
||
onchange = (event) => {}; | ||
``` | ||
|
||
## 事件类型 | ||
|
||
一个通用的 {{domxref("Event")}}。 | ||
|
||
## 示例 | ||
|
||
```js | ||
navigator.permissions | ||
.query({ name: "geolocation" }) | ||
.then((permissionStatus) => { | ||
console.log(`geolocation 权限状态为 ${permissionStatus.state}`); | ||
permissionStatus.onchange = () => { | ||
console.log(`geolocation 权限状态已更改为 ${permissionStatus.state}`); | ||
}; | ||
}); | ||
``` | ||
|
||
## 规范 | ||
|
||
{{Specifications}} | ||
|
||
## 浏览器兼容性 | ||
|
||
{{Compat}} |