在页面加载时进行监听
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL)
window.addEventListener('popstate', this.eventBackButton, false) // false阻止默认事件
}
页面销毁前或者销毁后取消监听
destroyed() {
window.removeEventListener('popstate', this.eventBackButton, false) // false阻止默认事件
}
方法里执行监听到点击返回按钮时执行的方法
// 监听手机点击返回按钮
eventBackButton() {
wx.closeWindow()
},