@[TOC](uni-app 安卓禁用侧滑返回/虚拟返回(vue3 hook))
hook
javascript
import { onBackPress } from "@dcloudio/uni-app"
export default function useDisableSwipeBack() {
onBackPress((options) => {
// 点击虚拟键或者侧滑的时候触发(不允许返回)
if (options.from === 'backbutton') {
return true
}
// 否则则允许返回
return false;
})
return {}
}
使用
javascript
import useDisableSwipeBack from "@/hooks/disableSwipeBack"
useDisableSwipeBack();