通常可以用到window.history.back();
window.history.go(-1);返回刷新上一页,
但当两种方法都不满足你的开发需求的时候,可以采用以下的方法。

从a页面,跳转到b页面,b页面的数据操作,会影响a页面的展示。那么在b页面里就可以使用,sessionStorage.setItem(“need-refresh”, true); 然后再进行window.history.go(-1)操作。

// 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);

版权声明:本文为liuchenxi原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/liuchenxi/p/9640800.html