跳到内容

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

来源

Source文档

贡献者

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 支持,优化包并清理 (#4349)
v10.7.1 于 2023/12/27
ce420 - fix: 修复 vue2 中的 tryOnMounted (#3658)
v10.7.0 于 2023/12/5
f2aeb - feat(tryOnMounted): 支持 target 参数 (#3185)

根据 MIT 许可证发布。