usePageLeave
响应式状态,用于显示鼠标是否离开页面。
演示
{
"isLeft": false
}用法
ts
import { usePageLeave } from '@vueuse/core'
const isLeft = usePageLeave()组件用法
此函数还通过
@vueuse/components包提供了一个无渲染组件版本。了解更多用法。
vue
<template>
<UsePageLeave v-slot="{ isLeft }">
Has Left Page: {{ isLeft }}
</UsePageLeave>
</template>类型声明
ts
/**
* Reactive state to show whether mouse leaves the page.
*
* @see https://vueuse.org.cn/usePageLeave
* @param options
*
* @__NO_SIDE_EFFECTS__
*/
export declare function usePageLeave(
options?: ConfigurableWindow,
): ShallowRef<boolean, boolean>
export type UsePageLeaveReturn = ReturnType<typeof usePageLeave>