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();
}
})