(history) {
let pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate === 'function') {
history.onpushstate({ state: state });
}
return pushState.apply(history, arguments);
};
let replaceState = history.replaceState;
history.replaceState = function(state) {
if (typeof history.onreplacestate === 'function') {
history.onreplacestate({ state: state });
}
return replaceState.apply(history, arguments);
};
})(window.history);
window.onhashchange = window.onpopstate = history.onpushstate = history.onreplacestate = function() { console.log('change!')};
根本无效