Skip to content

usePageLeave ​

Category
Export Size
625 B
Last Changed
4 months ago

响应式状态,用于显示鼠标是否离开页面。

Demo ​

{
  "isLeft": false
}

使用方法 ​

js
import { usePageLeave } from '@vueuse/core'

const isLeft = usePageLeave()

组件使用 ​

vue
<template>
  <UsePageLeave v-slot="{ isLeft }">
    是否离开页面: {{ isLeft }}
  </UsePageLeave>
</template>

Type Declarations ​

typescript
/**
 * Reactive state to show whether mouse leaves the page.
 *
 * @see https://vueuse.org/usePageLeave
 * @param options
 */
export declare function usePageLeave(
  options?: ConfigurableWindow,
): ShallowRef<boolean, boolean>

Source ​

Source • Demo • Docs

Contributors ​

Anthony Fu
丶远方
Fernando Fernández
Anthony Fu
vaakian X
lxhyl
wheat
Alex Kozack
Antério Vieira

Changelog ​

dd316 - feat: use passive event handlers everywhere is possible (#4477)
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)

Released under the MIT License.