1:公眾號(hào)手機(jī)返回問題微宝,在vue下可如下處理:
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);?