mounted:if (window.history && window.history.pushState) {
history.pushState(null,null,document.URL);
window.addEventListener('popstate',this.goBack,false);
}
destoryed: window.removeEventListener('popstate',this.goBack,false)
2:在純js下可做:
//返回操作
? pushHistory(){
? let state = {?
title: "home",?
url: "#"?
};?
window.history.pushState(state, "home", "#");?
? },
this.pushHistory();
window.addEventListener("popstate", function(e) {?
? wx.closeWindow();?
}, false);?