Skip to content

usePageLeave ​

Category
Export Size
625 B
Last Changed
5 minutes 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 ​

jojo

Changelog ​

No recent changes

Released under the MIT License.