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