在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()