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.dev.org.tw/usePageLeave
* @param options
*/
export declare function usePageLeave(
options?: ConfigurableWindow,
): ShallowRef<boolean, boolean>