From 6c391d0761ca53bc09367208438b58862545c973 Mon Sep 17 00:00:00 2001 From: skyclouds2001 <95597335+skyclouds2001@users.noreply.github.com> Date: Sat, 1 Feb 2025 12:45:32 +0800 Subject: [PATCH] [zh-CN]: Add translation for `NavigationDestination.key` --- .../api/navigationdestination/key/index.md | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 files/zh-cn/web/api/navigationdestination/key/index.md diff --git a/files/zh-cn/web/api/navigationdestination/key/index.md b/files/zh-cn/web/api/navigationdestination/key/index.md new file mode 100644 index 00000000000000..5b82d945aad6ba --- /dev/null +++ b/files/zh-cn/web/api/navigationdestination/key/index.md @@ -0,0 +1,38 @@ +--- +title: NavigationDestination:key 属性 +slug: Web/API/NavigationDestination/key +l10n: + sourceCommit: ac7f942ac73066dcf643f02f8b9f969ccf547220 +--- + +{{APIRef("Navigation API")}}{{SeeCompatTable}} + +{{domxref("NavigationDestination")}} 接口的 **`key`** 只读属性在 {{domxref("NavigateEvent.navigationType")}} 为 `traverse` 时返回目标 {{domxref("NavigationHistoryEntry")}} 的 {{domxref("NavigationHistoryEntry.key", "key")}} 值,否则返回空字符串。 + +`key` 是一个唯一的 UA 生成值,表示历史条目在历史条目列表中的位置,用于通过 {{domxref("Navigation.traverseTo()")}} 导航到历史记录中的此位置。它将被替换列表中的其他条目重用(即,如果 {{domxref("NavigateEvent.navigationType")}} 为 `replace`)。 + +## 值 + +表示目标 {{domxref("NavigationHistoryEntry")}} 的 `key` 的字符串,或者一个空字符串。 + +## 示例 + +```js +navigation.addEventListener("navigate", (event) => { + console.log(event.destination.key); +}); +``` + +## 规范 + +{{Specifications}} + +## 浏览器兼容性 + +{{Compat}} + +## 参见 + +- [现代客户端路由:导航 API](https://developer.chrome.google.cn/docs/web-platform/navigation-api/) +- [导航 API 说明](https://github.com/WICG/navigation-api/blob/main/README.md) +- Domenic Denicola 的[导航 API 在线演示](https://gigantic-honored-octagon.glitch.me/)