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

今天写一个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);
})

猜你喜欢

转载自www.cnblogs.com/chenyudi/p/12802266.html