useLocation
On this page

useLocation

返回当前位置对象。

¥Returns the current location object.

import { useLocation } from "@remix-run/react";

function SomeComponent() {
  const location = useLocation();
  // ...
}

属性

¥Properties

location.hash

当前 URL 的哈希值。

¥The hash of the current URL.

location.key

此位置的唯一键。

¥The unique key of this location.

location.pathname

当前 URL 的路径。

¥The path of the current URL.

location.search

当前 URL 的查询字符串。

¥The query string of the current URL.

location.state

<Link state>navigate 创建的位置的状态值。

¥The state value of the location created by <Link state> or navigate.

Remix v2.17 中文网 - 粤ICP备13048890号