1. 程式人生 > >react專案—單擊按鈕返回上一頁

react專案—單擊按鈕返回上一頁

// 如果使用hashHistory
import creatHistory from 'history/createHashHistory' 

// 如果使用createBrowserHistory
import creatHistory from 'history/createBrowserHistory' 

const history = creatHistory();

history.goBack();

下面的截圖是列印history的結果:

 

相關API:https://reacttraining.com/react-router/web/api/history