反应路由器matchPath
问题。
我有一个网址:/users/test?dp=1
,路径为/users/:id
当我们传递到matchpath
的{{1}}时,react-router
给出:id
。
我只想要test?dp=1
作为输出。我不想更改test
。
url
答案 0 :(得分:1)
这里是matchPath
上的参考。
您要做的是使用req.path
而不是req.url
,它包含URL的查询字符串部分。 matchPath
只能接收path
,而没有查询字符串。
您可以在这里看到提及: matchPath not working with queryParams in url #5285