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.