浏览器返回上一页和上一页页面数据不刷新


今天写一个vue使用axios的时候,修改完数据后,在使用浏览器的上一页返回去以后的发现页面斌没有变化。

然后百度了好久找到了,留一下。记录一下。具体什么原理也不知道,就知道管用,就行了。

  $(function () {


            if (window.history && window.history.pushState) {
                $(window).on('popstate', function () {
                    window.history.pushState('forward', null, '#');
                    window.history.forward(1);
                    location.replace(document.referrer);//刷新 
                });
            }

            window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
            window.history.forward(1);
})

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM