Skip to content

useMounted

类别
导出体积
122 B
上次更改
1 hour ago

在 ref 中表示组件是否已挂载。

示例

使用方法

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/useMounted
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function 
useMounted
():
ShallowRef
<boolean, boolean>

源码

源码演示文档

贡献者

一纸忘忧

更新日志

没有最近的更新日志