Skip to content
On this page

useMounted

使用ref记录挂载状态

Mounted state in ref.

例子

unmounted

Usage

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

const isMounted = useMounted()
import { useMounted } from '@vueuse/core'

const isMounted = useMounted()

这本质上是以下简写:

Which is essentially a shorthand of:

ts
const isMounted = ref(false)

onMounted(() => {
  isMounted.value = true
})
const isMounted = ref(false)

onMounted(() => {
  isMounted.value = true
})

Type Declarations

typescript
/**
 * Mounted state in ref.
 *
 * @see https://vueuse.org/useMounted
 * @param options
 */
export declare function useMounted(): Ref<boolean>
/**
 * Mounted state in ref.
 *
 * @see https://vueuse.org/useMounted
 * @param options
 */
export declare function useMounted(): Ref<boolean>

Source

Category
Export Size
777 B
Last Changed
last year

SourceDemoDocs

贡献者(Contributors)

日志(Changelog)

No recent changes

Released under the MIT License.