mounted() {
//监听浏览器左上角返回事件
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener('popstate', this.goBack, false);
}
},
//界面销毁时取消监听,防止对后续界面影响
destroyed () {
window.removeEventListener('popstate', this.goBack, false);
},
methods: {
/**
* 点击界面返回时,刷新界面
*/
goBack: function(){
window.history.go(0);
},
}
网友评论