当小程序在返回上一页需要弹出窗口让用户确认时,可以在有需要的页面的onLoad
、onReady
或者onShow
中添加以下代码
wx.enableAlertBeforeUnload({
message: "返回上页时弹出对话框的文字",
success: function (res) {
console.log("方法载入成功:", res)
},
fail: function (errMsg) {
console.log("方法载入失败:", errMsg);
},
});