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