跳到主要內容

tryOnBeforeMount

類別
匯出大小
163 B
上次變更
3 個月前

安全的 onBeforeMount。如果在元件生命週期內,則呼叫 onBeforeMount(),否則直接呼叫函式

用法

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

tryOnBeforeMount(() => {

})

類型宣告

typescript
/**
 * Call onBeforeMount() if it's inside a component lifecycle, if not, just call the function
 *
 * @param fn
 * @param sync if set to false, it will run in the nextTick() of Vue
 * @param target
 */
export declare function tryOnBeforeMount(
  fn: Fn,
  sync?: boolean,
  target?: any,
): void

原始碼

原始碼文件

貢獻者

Anthony Fu
Anthony Fu
Doctorwu
qiang
Eureka

更新日誌

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

依 MIT 許可證發布。