解决办法:
onLoad() {
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener("popstate", this.show11, false);
}
},
onUnload() {
window.removeEventListener("popstate", this.show11, false);
},
methods: {
show11() {
uni.showModal({
content: '保留此次编辑?',
cancelText: '不保留',
confirmText: '保留',
success: function (res) {
if (res.confirm) {
uni.showToast({
title: '用户点击保留',
duration: 1000
})
} else if (res.cancel) {
uni.showToast({
title: '用户点击不保留',
duration: 1000
})
}
}
})
}
}