JS监听VUE的HASH变化

dhso
2019/03/05 13:25
统计中
(function(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;

本文为 dhso 原创

发布在 http://blog.minws.com/jsjian-ting-vuede-hashbian-hua/

如有转载,请标明来源!

作者信息
姓名:dhso
热评文章
最新评论
文章概览