NavigationDestination:getState() 方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

NavigationDestination 接口的 getState() 方法根据需要返回由开发人员提供且与目标 NavigationHistoryEntry 或导航操作(例如 navigate())相关联的状态的克隆。

语法

js
getState()

参数

无。

返回值

表示状态的值。可以是任意类型。

如果未定义状态,则返回 undefined

异常

无。

示例

js
navigation.addEventListener("navigate", (event) => {
  console.log(event.destination.getState());
});

规范

Specification
HTML
# the-navigationdestination-interface:dom-navigationdestination-getstate-2

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getState
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

参见