Skip to content
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

[zh-cn]: add translation for PermissionStatus.change_event #19770

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions files/zh-cn/web/api/permissionstatus/change_event/index.md
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}}