---
title: "onBeforeRouteLeave"
description: "onBeforeRouteLeave 组合式函数允许在组件内注册路由守卫。"
canonical_url: "https://nuxt.zhcndoc.com/docs/4.x/api/utils/on-before-route-leave"
---
# onBeforeRouteLeave

> onBeforeRouteLeave 组合式函数允许在组件内注册路由守卫。

::read-more
```yaml [props]
icon: i-simple-icons-vuedotjs
to: https://router.vuejs.org/api/functions/onbeforerouteleave
title: Vue Router 文档
target: _blank
```
::

---

- [源码](https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/router.ts)


## Sitemap

See the full [sitemap](https://nuxt.zhcndoc.com/sitemap.md) for all pages.
