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