3 回答
TA貢獻1801條經(jīng)驗 獲得超8個贊
this.props.history.push("/new/url")
您可能想通過 historyprop從父組件到組件,如果操作不可用,則調(diào)用該操作。
TA貢獻1155條經(jīng)驗 獲得超0個贊
Redux-Saga
<Router> 元件React-Router
步驟:
安裝歷史NPM模塊- yarn add history或npm install history --save創(chuàng)建一個名為 history.js在你的 App.js級別文件夾(這是我的首選) // src/history.jsimport createHistory from 'history/createBrowserHistory';export default createHistory();`
將此歷史記錄對象添加到您的路由器組件中,如下所示 // src/App.jsimport history from '../your/path/to/history.js;'<Router history={history}>// Route tags here</Router>通過導(dǎo)入來調(diào)整URL,就像以前一樣 你的全球歷史目標: import history from '../your/path/to/history.js;'history.push('new/path/here/');
- 3 回答
- 0 關(guān)注
- 690 瀏覽
添加回答
舉報
