• 移动端页面返回,数据不刷新bug解决


    一,当安卓和ios都有问题的时候

    // a.html 设置刷新 检测缓存是否有标志 要是有就说明数据有变化  a.html跳转到b.html页面
    window.addEventListener("pageshow", function(){
        if(sessionStorage.getItem("need-refresh")){
            location.reload();
            sessionStorage.removeItem("need-refresh");
        }
    });
    
    // b.html 如果是数据变化了就写一条缓存   b.html返回到a.html页面
    sessionStorage.setItem("need-refresh", true);
    

      

    二、当只有ios端有问题的时候

    $(function() {
        var isPageHide = false;
        window.addEventListener('pageshow', function() {
           if(isPageHide) {
                window.location.reload();
           }
        });
        window.addEventListener('pagehide', function() {
           isPageHide = true;
        });
    })

      

    参考地址:https://www.cnblogs.com/wangmaoling/p/8022561.html

    日常所遇,随手而记。
  • 相关阅读:
    vim操作
    git命令
    Python笔记(二)
    python笔记
    gdb笔记 ---《Linux.C编程一站式学习》
    python笔记——dict和set
    echo $?
    FastDFS与Nginx环境配置
    Nginx依赖库安装
    mixin多继承包装过程
  • 原文地址:https://www.cnblogs.com/zhihou/p/9047229.html
Copyright © 2020-2023  润新知