tryOnBeforeUnmount
安全的 onBeforeUnmount
。如果在元件生命週期內,則呼叫 onBeforeUnmount()
,否則不執行任何操作
用法
js
import { tryOnBeforeUnmount } from '@vueuse/core'
tryOnBeforeUnmount(() => {
})
類型宣告
typescript
/**
* Call onBeforeUnmount() if it's inside a component lifecycle, if not, do nothing
*
* @param fn
* @param target
*/
export declare function tryOnBeforeUnmount(fn: Fn, target?: any): void