跳到主要內容

tryOnBeforeUnmount

類別
匯出大小
148 B
最後變更
3 個月前

安全的 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

原始碼

原始碼文件

貢獻者

Anthony Fu
Ngheizit
Anthony Fu
Doctorwu
qiang

變更日誌

v12.3.0 於 1/2/2025
59f75 - feat(toValue): 棄用 `@vueuse/shared` 中的 `toValue`,改用 Vue 原生方法
v12.0.0-beta.1 於 11/21/2024
0a9ed - feat!: 移除 Vue 2 支援,最佳化 bundle 並清理 (#4349)
v10.7.1 於 12/27/2023
ce420 - fix: 修復 vue2 中的 `tryOnMounted` (#3658)
v10.7.0 於 12/5/2023
f2aeb - feat(tryOnMounted): 支援 target 參數 (#3185)

以 MIT 授權條款發布。