主题
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