主题
tryOnBeforeUnmount
安全 onBeforeUnmount
。如果 onBeforeUnmount()
在组件生命周期内,则调用 onBeforeUnmount()
,如果不在组件生命周期内,则不执行任何操作
¥Safe onBeforeUnmount
. Call onBeforeUnmount()
if it's inside a component lifecycle, if not, do nothing
用法
¥Usage
js
import { tryOnBeforeUnmount } from '@vueuse/core'
tryOnBeforeUnmount(() => {
})
类型声明
typescript
/**
* Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
*
* @param fn
* @param target
*/
export declare function tryOnBeforeUnmount(fn: Fn, target?: any): void