简体   繁体   English

如何在React-Router V4中访问抽象当前路径

[英]How to access abstract current path in react-router v4

Using react-router v4, how should I go about getting the current abstract path. 使用react-router v4,我应该如何获取当前的抽象路径。 For example, I can access this.props.location when using withRouter(...) but this gives /students/19 , when I want students/:id etc. This functionality is desired for a logging tool. 例如,当使用withRouter(...)时,我可以访问this.props.location ,但是当我想要students/:id等时,它给出/students/19此功能是日志记录工具所需要的。

How should I accomplish this? 我应该如何做到这一点?

在此处输入图片说明

Use this.props.match.path . 使用this.props.match.path I believe that's what you need. 我相信这就是您所需要的。

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

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