vue实现:
mounted(){
if(window.history&&window.history.pushState){
//history.pushState(data,title,url) 每次执行会增加一条历史记录,浏览器在返回时,不会返回前一页面
history.pushState(null,null,document.URL);
window.addEventListener('popstate',this.quit,false)
}
},
beforeDestroy(){
window.removeEventListener('popstate',this.quit,false)
},
methods: {
quit(){
//微信退出当前网页
wx.closeWindow();
},
}