监听url地址栏变化

使用window.onhashchange方法

    window.onhashchange = function (e) {
        console.log(e);
        console.log(e.newURL);
        console.log(e.oldURL);
    }

PS:适用于路由方法,可以解决按返回按钮页面不刷新的问题。

posted @ 2017-10-09 11:39  潇影D  阅读(5316)  评论(0编辑  收藏  举报