committed by
trae-solo-agent
co-authored by
Kimi-K3.1-Pro
parent
d731fc1da3
commit
a45a3d7a86
@@ -0,0 +1,16 @@
|
||||
// 使用微信原生返回拦截,导航栏返回和手势返回都不会静默丢失未保存内容。
|
||||
function setUnsavedGuard(enabled) {
|
||||
if (enabled && wx.canIUse('enableAlertBeforeUnload')) {
|
||||
wx.enableAlertBeforeUnload({
|
||||
message: '当前修改尚未保存,确定要离开吗?'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!enabled && wx.canIUse('disableAlertBeforeUnload')) {
|
||||
wx.disableAlertBeforeUnload()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
setUnsavedGuard
|
||||
}
|
||||
Reference in New Issue
Block a user