跳到主要内容

tryOnBeforeMount

分类
导出大小
163 B
上次更改
上个月

安全的 onBeforeMount。如果它在组件生命周期内,则调用 onBeforeMount();如果不在,则直接调用该函数。

用法

ts
import { 
tryOnBeforeMount
} from '@vueuse/core'
tryOnBeforeMount
(() => {
})

类型声明

ts
/**
 * 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
?:
ComponentInternalInstance
| null,
): void

来源

源码文档

贡献者

Anthony Fu
Arthur Darkstone
SerKo
Anthony Fu
Doctorwu
qiang
Eureka

更新日志

v14.0.0
a49a3 - fix: 更新参数类型以在生命周期中使用 ComponentInternalInstance (问题 #5060)
v12.3.0
59f75 - feat(toValue): 废弃 @vueuse/shared 中的 toValue,转而使用 Vue 的原生函数
0a9ed - feat!: 放弃对 Vue 2 的支持,优化打包并清理 (#4349)
v10.7.1
ce420 - fix: 修复 vue2 中的 tryOnMounted (问题 #3658)
v10.7.0
f2aeb - feat(tryOnMounted): 支持 target 参数 (问题 #3185)

根据 MIT 许可证发布。