window.history.go返回上一个页面无刷新问题

B页面   -------》  A页面

B页面:

sessionStorage.setItem("refresh","true");
window.history.go(-1);

A页面:

window.addEventListener('pageshow', function(event) {
    if(event.persisted) { // ios 有效, android 和 pc 每次都是 false
        location.reload();
    } else { // ios 除外
        if(sessionStorage.getItem('refresh') === 'true') {
            location.reload();
        }
     }
    sessionStorage.removeItem('refresh');
});

如有其它更好的方法,可在评论区留言...

原文地址:https://www.cnblogs.com/zsj-02-14/p/13525614.html