问题
This answer doesn't quite cover it since it appears that you have to pass a reconstructed URL into pathname
If I am on the child page of these routes:
<Route name="Parent" path="/parent/:parentId" component={Parent}>
<Route name="Child" path="/child/:childId" component={Child}>
how do I programmatically update the :parentId
without having to re-construct the entire URL?
Something along the lines of history.push({ ...., params: {parentId: 'newParent'}})
would be ideal.
Thanks!
来源:https://stackoverflow.com/questions/42729802/how-do-you-programmatically-update-url-params-in-react-router