useResolvedPath
在本页

useResolvedPath

概述

参考文档 ↗

根据当前位置解析给定的 to 值的路径名。类似于 useHref,但返回一个 Path 对象而不是字符串。

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; // ""
}

签名

useResolvedPath(to, __namedParameters): Path

参数

to

暂无文档

__namedParameters

暂无文档

文档与示例 CC 4.0