tryOnUnmounted
安全的 onUnmounted
。如果在元件生命週期內呼叫 onUnmounted()
,否則不執行任何動作
用法
js
import { tryOnUnmounted } from '@vueuse/core'
tryOnUnmounted(() => {
})
類型宣告
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