Skip to content
On this page

组合式 API: onBeforeRouteLeave()

onBeforeRouteLeave()

该函数允许你在 setup 中直接注册 beforeRouteLeave 路由守卫。

  • 类型

    ts
    function onBeforeRouteLeave(guard: NavigationGuardWithThis): void
  • 示例

    js
    import {
      onBeforeRouteLeave
    } from '@/uni-simple-router'
    
    export default {
      setup(){
        onBeforeRouteLeave((to,from)=>{
          console.log(to)
        })
      }
    }
  • 参考 指南 - 组合式 API指南 - 组件内的守卫

组合式 API: onBeforeRouteLeave() has loaded