反应路由器匹配路径问题

时间:2020-07-16 18:27:21

标签: javascript reactjs react-router react-redux-form

反应路由器matchPath问题。

我有一个网址:/users/test?dp=1,路径为/users/:id

当我们传递到matchpath的{​​{1}}时,react-router给出:id。 我只想要test?dp=1作为输出。我不想更改test

url

1 个答案:

答案 0 :(得分:1)

@GauthamShetty

这里是matchPath上的参考。

您要做的是使用req.path而不是req.url,它包含URL的查询字符串部分。 matchPath只能接收path,而没有查询字符串。

您可以在这里看到提及: matchPath not working with queryParams in url #5285