解决微信h5原生ios虚拟键返回不刷新问题

 1 if (isIos()) {
 2             let isPageHide = false;
 3             window.addEventListener('pageshow', function () {
 4                 if (isPageHide) {
 5                     window.location.reload();
 6                 }
 7             });
 8             window.addEventListener('pagehide', function () {
 9                 isPageHide = true;
10             });
11         } else {
12             let reload = sessionStorage.getItem("reload");
13             if (reload) {
14                 sessionStorage.removeItem("reload")
15                 location.reload()
16             }
17         }

isIos方法(判断是安卓还是ios):

function isIos(){
            if(/iP(ad|hone|od)/.test(navigator.userAgent)){
                return true
            }else{
                return false
            }
        }

猜你喜欢

转载自www.cnblogs.com/jay-sans/p/10968088.html