Skip to content

tryOnBeforeUnmount

Category
Export Size
148 B
Last Changed
3 months ago

安全的 onBeforeUnmount。如果在组件生命周期内,调用 onBeforeUnmount(),如果不是,不执行任何操作。

用法

js
import { tryOnBeforeUnmount } from '@vueuse/core'

tryOnBeforeUnmount(() => {

})

Type Declarations

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

Source

SourceDocs

Contributors

Anthony Fu
丶远方
Ngheizit
Anthony Fu
Doctorwu
qiang

Changelog

59f75 - feat(toValue): deprecate toValue from @vueuse/shared in favor of Vue's native
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
ce420 - fix: fix tryOnMounted in vue2 (#3658)
f2aeb - feat(tryOnMounted): support target arguement (#3185)

Released under the MIT License.