瀏覽器返回上一頁和上一頁頁面數據不刷新


今天寫一個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