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