Lzh on GitHub

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

用法

import { usePageLeave } from '@vueuse/core'

const isLeft = usePageLeave()

组件用法

此函数也通过 @vueuse/components提供了无渲染组件版本了解更多关于用法的信息

<template>
  <UsePageLeave v-slot="{ isLeft }">
    Has Left Page: {{ isLeft }}
  </UsePageLeave>
</template>

类型声明

/**
 * 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>