直接上代码
mounted() {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.fun, false); //false阻止默认事件 this.fun是指返回按建实际要执行的方法
}
}
destroyed(){ // 销毁时取消监听
window.removeEventListener('popstate', this.fun, false);//false阻止默认事件
},