相对于当前位置解析给定 to 值的路径名。类似于 useHref,但返回 Path 而不是字符串。
to
import { useResolvedPath } from "react-router"function SomeComponent() { // if the user is at /dashboard/profile let path = useResolvedPath("../accounts") path.pathname // "/dashboard/accounts" path.search // "" path.hash // ""} Copy
import { useResolvedPath } from "react-router"function SomeComponent() { // if the user is at /dashboard/profile let path = useResolvedPath("../accounts") path.pathname // "/dashboard/accounts" path.search // "" path.hash // ""}
可选
相对于当前位置解析给定
to
值的路径名。类似于 useHref,但返回 Path 而不是字符串。