简体   繁体   English

我如何检查路径名是否存在于反应中?

[英]How can i check pathname is exist in react?

I have a pathname like this:我有一个这样的路径名:

'/student/projects/41XrUP7E2-fHhOfzIK'

"/student/projects/41XrUP7E2-fHhOfzIK/edit"

and array of router path:和路由器路径数组:

['/student/project/:contactid/school', "/student/projects/:projectId/edit", "/orderers/projects/:projectId"]

How can i check pathname is exist in app?如何检查应用程序中是否存在路径名?

You need to use matchPath function from react-router.您需要使用来自 react-router 的 matchPath function。

visit Check if react-router path is active访问检查 react-router 路径是否处于活动状态

Hope it will clarify your question希望它能澄清你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM