useMounted
挂载状态的引用。
演示
用法
ts
import { useMounted } from '@vueuse/core'
const isMounted = useMounted()
这实际上是以下内容的简写
ts
const isMounted = ref(false)
onMounted(() => {
isMounted.value = true
})
类型声明
ts
/**
* Mounted state in ref.
*
* @see https://vueuse.org.cn/useMounted
*
* @__NO_SIDE_EFFECTS__
*/
export declare function useMounted(): ShallowRef<boolean, boolean>