在example here和issue comment中,建議使用history的useBeforeUnload函數。 但是,此功能已消失。它似乎是removed without replacement in the current 4.x version: 刪除了「中間件」API(即所有「使用」功能)。 現在爲了顯示確認對話框,處理這些「卸載」情況時處理這些問題的好方法是什麼?
我使用create-react-app,我有這樣一行: import createHistory from 'history/lib/createBrowserHistory'
但是,這並不工作,它拋出一個錯誤: Error in ./src/deps/history.js.
Module not found: 'history/lib/createBrowserHistory'
in /
這是我在Require.js上的第一次嘗試,我試圖弄清楚如何使用jQuery插件,特別是應該管理我的SPA的history.js。下面的代碼位於main.js中,並且腳本運行,但我無法計算如何實際使用History.pushState(),State.getState()和其他插件方法。我在控制檯中不斷收到"getState is not a function"錯誤消息。 (function()