H5移动端,ios从后台返回到app,页面会白一下

visibilitychange事件可以检查从后台返回事件,然后通过添加div,强制浏览器刷新页面
var divEle = document.createElement("DIV"); divEle.style.position = "absolute"; divEle.style.left = "0px"; divEle.style.top = "0px"; divEle.style.width = "100%"; divEle.style.height = "100%"; divEle.style.zIndex = "9999999"; divEle.style.backgroundColor = "#000"; document.addEventListener("visibilitychange", () => { try { if (document.hidden) { document.body.appendChild(divEle); } else { document.body.removeChild(divEle); } } catch (e) { } });

 

相关文章