react router保存上一页路由

2022-12-09163次阅读React

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;
}

 

上一篇: HTML属性capture是否启用用户的前置或后置摄像头和/或麦克风  下一篇: js数组实例方法copyWithin  

react router保存上一页路由相关文章