小编gho*_*hri的帖子

React-Router V6 检查路径是否与模式匹配

我正在尝试在react-router v6中检查“/admin/posts/new”到“/admin/*”。我发现有一个matchRoutes函数

import { useLocation } from "react-router";
const { pathname } = useLocation();
const isAdminPath = someMatchFunc(pathname,"/admin/*") <<<< something goes here returns true or null
Run Code Online (Sandbox Code Playgroud)

reactjs react-router

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

react-router ×1

reactjs ×1