useMounted
在 ref 中表示组件是否已挂载。
Demo
unmounted
使用方法
js
import { useMounted } from '@vueuse/core'
const isMounted = useMounted()
这本质上相当于:
ts
const isMounted = ref(false)
onMounted(() => {
isMounted.value = true
})
类型声明
typescript
/**
* Mounted state in ref.
*
* @see https://vueuse.org/useMounted
*/
export declare function useMounted(): Ref<boolean, boolean>
Source
贡献者
Anthony Fu
yanbowen
丶远方
变更日志
v10.10.0
on 5/27/2024v10.9.0
on 2/27/2024v10.8.0
on 2/20/2024v10.0.0-beta.3
on 4/12/20231aab1
- fix: check for the current instance