回退、go(-1)返回上一页刷新
window.addEventListener('pageshow', (event) => {
const navigationType = window.performance && window.performance.navigation.type === 2;
const isBackForward = window.performance.getEntriesByType("navigation")[0] && window.performance.getEntriesByType("navigation")[0].type === 'back_forward';
if(event.persisted || navigationType || isBackForward) {
window.location.reload();
}
}, false);
页面显示就刷新
if (document.visibilityState) {
document.addEventListener('visibilitychange', function() {
if (document.visibilityState === 'visible') {
window.location.reload();
}
});
}
window.onpageshow = function() {
window.location.reload();
};