我在 react-router-dom 中有这样的路径:
<BrowserRouter>
<div>
<Route exact path='/(index.html)?' component={Home}/> {/* app = home */}
<Route path='/register' component={Registration}/>
</div>
</BrowserRouter>
一切正常,现在在我的组件中的任何地方我想通过 onClick 更改路径,代码如下:
<button onClick={() => history.push('/the/path') }> change path </button>
我怎样才能做到这一点?