react-app-shell
Version:
react打包脚本和example, 这里的版本请忽略
32 lines (26 loc) • 979 B
JavaScript
const createHistory = require('history').createBrowserHistory;
// The base URL of the app
const basename = process.env.PUBLIC_URL || '';
const options = {
basename,
// // 离开确认
// getUserConfirmation: (message, callback) => {
// console.log('getUserConfirmation', message, callback);
// callback(window.confirm(message));
// }
};
const history = createHistory(options);
// // 阻止
// history.block((location, action) => {
// // The location and action arguments indicate the location
// // we're transitioning to and how we're getting there.
//
// // A common use case is to prevent the user from leaving the
// // page if there's a form they haven't submitted yet.
// console.log('block', location, action);
// return 'Are you sure you want to leave this page?';
// });
history.listen((location, action) => {
console.log('history', action, location.pathname, location.state);
});
export default history;