react router保存上一页路由
import { createBrowserHistory, Location } from 'history';
const history = createBrowserHistory({
basename:
process.env.NODE_ENV === 'development' ? undefined : '//framework',
});
// 导出到全局
let previousLocation: Location;
let currentLocation: Location;
history.listen((location) => {
previousLocation = currentLocation;
currentLocation = location;
});
export function getPreviousLocation() {
return previousLocation;
}