You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constbindEventListener=function(type){consthistoryEvent=history[type];// 返回的执行函数returnfunction(){// 重新绑定现有事件constnewEvent=historyEvent.apply(this,arguments);// 创建新事件并执行conste=newEvent(type);e.arguments=arguments;window.dispatchEvent(e);// 返回原有的事件returnnewEvent;};};history.pushState=bindEventListener('pushState');history.replaceState=bindEventListener('replaceState');---window.addEventListener('replaceState',function(e){console.log('THEY DID IT AGAIN! replaceState');});window.addEventListener('pushState',function(e){console.log('THEY DID IT AGAIN! pushState');});
history.popstate 可以监听路由的变化,但只针对 history.go、history.back、history.forward 事件有效果
history.pushState 和 history.replaceState 没有相应的监听事件,如何实现?
The text was updated successfully, but these errors were encountered: