ios微信返回上一页不刷新

1.尝试过给history保存的url加时间戳,没有解决。
` $(function () {
var _search;
_search = window.location.search;
var _sInd = _search.indexOf('time=');
var _eInd;
if (_sInd != -1) {
_eInd = _search.indexOf('&', _sInd);
var tmp;
if (_eInd != -1) {
tmp = _search.substring(_sInd + 5, _eInd);

        } else {
            tmp = _search.substring(_sInd + 5);
        }
        _search.substring(0, _sInd + 5) + new Date().getTime() + _search.substring(_eInd);

    } else {
        if (_search.indexOf('?') != -1) {
            _search = _search + '&time=' + (+new Date().getTime());
        } else {
            _search = '?time=' + (+new Date().getTime());
        }

    }
    window.history.replaceState({}, "todo", window.location.pathname + _search + window.location.hash);
});`

第2中方式:监听pageshow事件,可以解决不刷新页面问题。
window.addEventListener('pageshow', function (event) {
if (event.persisted) {
window.location.reload();
}
})


image.png
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容