tryOnBeforeUnmount
安全的 onBeforeUnmount
。如果在组件生命周期内,调用 onBeforeUnmount()
,如果不是,不执行任何操作。
用法
js
import { tryOnBeforeUnmount } from '@vueuse/core'
tryOnBeforeUnmount(() => {
})
Type Declarations
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