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
.