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