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