useMounted ​
Mounted state in ref.
Demo ​
unmounted
Usage ​
js
import { useMounted } from '@vueuse/core'
const isMounted = useMounted()
Which is essentially a shorthand of:
ts
const isMounted = ref(false)
onMounted(() => {
isMounted.value = true
})
Type Declarations ​
typescript
/**
* Mounted state in ref.
*
* @see https://vueuse.org/useMounted
*/
export declare function useMounted(): Ref<boolean>
Source ​
Contributors ​
Anthony Fu
yanbowen