Skip to content

tryOnMounted

安全 onMounted。如果它在组件生命周期内,则调用 onMounted(),如果不在组件生命周期内,则仅调用该函数

¥Safe onMounted. Call onMounted() if it's inside a component lifecycle, if not, just call the function

用法

¥Usage

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

tryOnMounted(() => {

})

类型声明

typescript
/**
 * Call onMounted() 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 tryOnMounted(fn: Fn, sync?: boolean, target?: any): void

源代码

源代码文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号