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