方法名称:wx.enableAlertBeforeUnload
实现功能:拦截页面返回,返回上页前弹出询问对话框
文档链接&图片:https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
文档说明
代码示例
onLoad: function(){
wx.enableAlertBeforeUnload({
message: "返回上页时弹出对话框1212",
success: function (res) {
console.log("方法注册成功:", res);
},
fail: function (errMsg) {
console.log("方法注册失败:", errMsg);
},
});
}
效果图